##
## Monument by ViSa, this file has been edited by Keldath, TAfirehawk Mrgenie and Rockinroger. we thank GIR 1000times for supplying his mod to us
## vielen dank an die Hansastadt im Norden
##

from CvPythonExtensions import *
import CvUtil

import Popup as PyPopup
import PyHelpers
import CvConfigParser
import sys


gc = CyGlobalContext()

PyPlayer = PyHelpers.PyPlayer
PyGame = PyHelpers.PyGame()
PyInfo = PyHelpers.PyInfo

# maximum exp units get from the mil acadamy
g_expBarracsMax = 5

def loadConfigurationData():        

	global g_expBarracsMax

		
	# loads the ViSa ini file
	config = CvConfigParser.CvConfigParser("ViSa_v3.ini")

	# If we actually were able to open the "ViSa_v3.ini" file then read in the values.
	# otherwise we'll keep the default values that were set at the top of this file.
	if(config != None):
		g_expBarracsMax = config.getint("Monument Mod","Military Academy Max Experience", 5)


class Monument:

	def __init__(self):
	
		loadConfigurationData()


###############################################################################################################################################
###############################################################################################################################################

        #####################################################################################################################
                #############################################
                ### National Special Force Training Camp  ###
                ###		free Experience		  ###
                #############################################
        #####################################################################################################################
	def NSFTCFreeExperience(self, actualGameTurn ):

		
		### check every fifth turn makes game faster###
		if ( ( actualGameTurn % 5) == 0 ):
			barracksChance = 10
			
			### player list ###
			lExp = []
					
			### NSFTC var = is there a player with the NSFTC wonder? ###
			NSFTC_true = 0
			for iPlayer in range(gc.getMAX_PLAYERS()):

				### make player list (only 0 use) ###
				lExp.append(0)
				pPlayer = gc.getPlayer(iPlayer)
				if ((pPlayer.isAlive()) or (pPlayer.isBarbarian())):

					### look in all cities of each player and search for NSFTC ###
					for iCity in range(pPlayer.getNumCities()):
						pCity = pPlayer.getCity(iCity)
						if pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_MILITARY_ACADEMY')):

							### if there is at least one player with the NSFTC set the NSFTC var to 1 ###
							NSFTC_true = 1

							### check if the player with the NSFTC have cities with barrack ###
							for iiCity in range(pPlayer.getNumCities()):
								ppCity = pPlayer.getCity(iiCity)
								if ppCity.hasBuilding(gc.getInfoTypeForString('BUILDING_BARRACKS')):

									### check all units in city with barracks ###
									for iUnit in range(ppCity.plot().getNumUnits()):
										pUnit = ppCity.plot().getUnit(iUnit)
										uType = pUnit.getUnitCombatType()

										### check only land combat units ###										
										if ( (uType != gc.getInfoTypeForString("UNITCOMBAT_NAVAL")) and (uType > gc.getInfoTypeForString("NO_UNITCOMBAT")) ):
											### check only own units in these cities ###
											if (pUnit.getOwner() == ppCity.getOwner()):

												### only check units with less than barracksMaxExp experience (e.g. 10 experience) ###
												if (pUnit.getExperience() < g_expBarracsMax):

													### free experience chance ###
													iRandNum = CyGame().getSorenRandNum(barracksChance, "Barracks Training")
													if (iRandNum == 0):

														### set free experience ###
														pUnit.changeExperience(1, g_expBarracsMax, False, True)
														### remember which player get how many free experience points in the turn ###
														lExp[iPlayer] += 1
			### ausgabe ###
			### only look here if some1 have the NSFTC ###
			if ( NSFTC_true == 1 ):
				for iPlayer in range(gc.getMAX_PLAYERS()):
					pPlayer = gc.getPlayer(iPlayer)
					n_units = lExp[iPlayer]
					if ( n_units == 1):
						CyInterface().addMessage(pPlayer.getID(),false,10,CyTranslator().getText("TXT_KEY_NSFTC_GAMETXT2",()),'',0,'',ColorTypes(5), -1, -1,True,True)
						### message: The National Special Force Training Camp provides one Experience Point to one Unit in your Empire! ###
					if ( n_units >= 2):
						CyInterface().addMessage(pPlayer.getID(),false,10,CyTranslator().getText("TXT_KEY_NSFTC_GAMETXT3",(n_units,n_units)),'',0,'',ColorTypes(5), -1, -1,True,True)
						### message: The National Special Force Training Camp provides 1 Experience Point to %d1 Units in your Empire! ###

###############################################################################################################################################
###############################################################################################################################################
						
	#####################################################################################################################	
                ######################################
                ### ALWAYS WAR !!!!!!!!!!!!!!!!!!! ###
                ######################################
        #####################################################################################################################
							
	### if you want always war! (it is different from the vanilla civ4 always war option: vanilla civ4 = only you have war against all other player, but the ai dont have always war again the other AIs) ###
	### with this option you and all other AIs have war against all other players ###
	### use this option only with the war option, else you have a lot of diplomacy pop ups (you will see) ###

	def alWaysWar(self):

		for iPlayer in range(gc.getMAX_PLAYERS()):
			pPlayer = gc.getPlayer(iPlayer)

			### with this check you make sure that not you declare war on the AIs; now the AIs declare war on you - nothing important ###
			if ( pPlayer.isHuman() == false ):
				if ( pPlayer.isAlive() ):

					### only declare war on players not in your team ###
					pTeam = pPlayer.getTeam()
					eTeam = gc.getTeam(pTeam)
					for i in range(gc.getMAX_PLAYERS()):
						p2Player = gc.getPlayer(i)
						p2Team = p2Player.getTeam()
						if ( p2Player.isAlive() ):
							if (eTeam.isAtWar(p2Team) == False and pTeam != p2Team):
								eTeam.declareWar(p2Team, False)

	
###############################################################################################################################################
###############################################################################################################################################

        #####################################################################################################################
                ##########################
                ### CRUSADE WONDER     ###
                ##########################
	#####################################################################################################################
	def CrusadeWonder(self, argsList):

		iGameTurn, iPlayer = argsList		
		pPlayer = gc.getPlayer(iPlayer)
		pTID = pPlayer.getTeam()
		if ((pPlayer.isAlive()) or (pPlayer.isBarbarian())):
			b_city_guard = gc.getInfoTypeForString('BUILDING_STADTWACHE')
			uc_trebuchet = gc.getInfoTypeForString("UNITCLASS_TREBUCHET")
			uc_cannon = gc.getInfoTypeForString("UNITCLASS_CANNON")
			uc_artillery = gc.getInfoTypeForString("UNITCLASS_ARTILLERY")
			p_city_guard = gc.getInfoTypeForString("PROMOTION_CITY_GUARD")


			### filter to improve late gameplay ###
			if ( gc.getTeam(pTID).isHasTech(gc.getInfoTypeForString("TECH_RIFLING")) == False ):
				if ( gc.getTeam(pTID).isHasTech(gc.getInfoTypeForString("TECH_THEOLOGY")) == True ):
					if ( gc.getTeam(pTID).isHasTech(gc.getInfoTypeForString("TECH_FEUDALISM")) == True ):
                                                ### do you have crusade wonder? ###
						b_crusade = gc.getInfoTypeForString("BUILDING_CRUSADE")
						for iCity in range(pPlayer.getNumCities()):
							pCity = pPlayer.getCity(iCity)
							if pCity.hasBuilding(b_crusade):
								### chances depending on game speed ###
								basechance = 10
								estiEnd = CyGame().getEstimateEndTurn()
								if ( estiEnd >= 1100 ):
									basechance = basechance
								elif ( estiEnd >= 850 ):
									basechance = 9
								elif ( estiEnd >= 450 ):
									basechance = 8
								elif ( estiEnd >= 300 ):
									basechance = 7
								elif ( estiEnd >= 10 ):
									basechance = 6
								else:
									basechance = basechance

								### chance for free templar knight ###
								chance = CyGame().getSorenRandNum(basechance + 10, "free Templar chance")
								if ( chance == 0 ):
									### search for cities >= 5 with state religion ###
									lppCityUber5 = []
									for iiCity in range(pPlayer.getNumCities()):
										ppCity = pPlayer.getCity(iiCity)
										if ( ppCity.getPopulation() >= 5 ):
											if ( ppCity.isHasReligion(pPlayer.getStateReligion()) ):
												lppCityUber5.append(ppCity)
									### select one of the >= 5 cities ###
									if ( len(lppCityUber5) != 0 ):
										chance = CyGame().getSorenRandNum(len(lppCityUber5), "which city")
										ppCity = lppCityUber5[chance]
										iX = ppCity.getX()
										iY = ppCity.getY()
										### give a free Templar Knight to the selected city  and reduce the population by 1 ###
										pPlayer.initUnit(gc.getInfoTypeForString("UNIT_KNIGHT_TEMPLAR"), iX, iY, UnitAITypes.UNITAI_ATTACK_CITY )
										ppCity.changePopulation(-1)
										### ausgabe templer knight ###
										CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_CRUSADE_WONDER_GAMETXT6",(ppCity.getName(),ppCity.getName())),'',0,'Art/Interface/Buttons/Units/knight_templar.dds',ColorTypes(44), iX, iY,True,True)
										### message: In %s the Crusade Wonder provides a free Templar Knight! ###

								### chance for state religion spread in own cities ###
								chance = CyGame().getSorenRandNum(basechance, "free state religion spread chance")
								if ( chance == 0 ):
									### search for cities without state religion ###
									lppCityUber5 = []
									for iiCity in range(pPlayer.getNumCities()):
										ppCity = pPlayer.getCity(iiCity)
										if ( not ppCity.isHasReligion(pPlayer.getStateReligion()) ):
											lppCityUber5.append(ppCity)
																		### select one of the cities without state religion ###
									if ( len(lppCityUber5) != 0 ):
										chance = CyGame().getSorenRandNum(len(lppCityUber5), "which city")
										ppCity = lppCityUber5[chance]
																			### set state religion in the city + ausgabe ###
										ppCity.setHasReligion(pPlayer.getStateReligion(), true, true, true)
										
        #####################################################################################################################
                #########################################################
                ### City Guard Trebuchet/Siege Gun/Artillery and FLAK ###
                #########################################################
	#####################################################################################################################
			### filter ###
			if ( gc.getTeam(pTID).isHasTech(gc.getInfoTypeForString("TECH_GUILDS")) == true):

				### chance for free City Guard Unit ###
				basechance = 20
				
				### chance for free City Guard Unit (better chanece if you have nationhood and/or police state civic) ###
				if ( pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LEGAL'))==gc.getInfoTypeForString('CIVIC_NATIONHOOD') ):
					basechance -= 5
				if ( pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_GOVERNMENT'))==gc.getInfoTypeForString('CIVIC_POLICE_STATE') ):
					basechance -= 5
					
				### chance for free City Guard Unit (better chanece with higher game speed) ###
				estiEnd = CyGame().getEstimateEndTurn()
				if ( estiEnd >= 1100 ):
					basechance = basechance
				elif ( estiEnd >= 850 ):
					basechance -= 2
				elif ( estiEnd >= 450 ):
					basechance -= 4
				elif ( estiEnd >= 300 ):
					basechance -= 6
				elif ( estiEnd >= 10 ):
					basechance -= 8
				else:
					basechance = basechance
				if ( basechance <= 5 ):
					basechance = 5
				chance = CyGame().getSorenRandNum(basechance, "Stadtwache ZU")

				if ( chance == 0 ):
					uc_flak = gc.getInfoTypeForString("UNITCLASS_FLAK88")
					t_flight = gc.getInfoTypeForString("TECH_FLIGHT")
					t_artillery = gc.getInfoTypeForString("TECH_ARTILLERY")
					pNewUnit = 0

					### check if the city has the city guard improvement ###
					for iCity in range(pPlayer.getNumCities()):
												
						### (maximal one free city guard unit per turn) ###
						if ( pNewUnit == 0 ):
							pCity = pPlayer.getCity(iCity)
							if pCity.hasBuilding(b_city_guard):
																
								### check what kind of city guard is in the city ###
								u_free_CG_unit = 1
								
								### l_TYPEofCG_Unit = [ FLAK_CG , SIEGE_CG , CITYGUARD_CG ] ###
								l_TYPEofCG_Unit = [0,0,0]

								for iUnit in range(pCity.plot().getNumUnits()):
									pUnit = pCity.plot().getUnit(iUnit)
									if ( pUnit.isHasPromotion(p_city_guard) ):
										if ( pUnit.getUnitClassType() == uc_flak ):
											l_TYPEofCG_Unit[0] = 1
										elif ( pUnit.getUnitClassType()==uc_trebuchet or pUnit.getUnitClassType()==uc_cannon or pUnit.getUnitClassType()==uc_artillery ):
											l_TYPEofCG_Unit[1] = 1
										elif ( pUnit.getUnitClassType() != uc_flak and pUnit.getUnitClassType() != uc_trebuchet and pUnit.getUnitClassType() != uc_cannon and pUnit.getUnitClassType() != uc_artillery ):
											l_TYPEofCG_Unit[2] = 1
											
                                                                ### do the city need CG units? ###
                                                                ### [1,1,1] go to next city if this city has already one flak_cg, siege_cg and CG_cg unit ###
								if ( l_TYPEofCG_Unit[0]==1 and l_TYPEofCG_Unit[1]==1 and l_TYPEofCG_Unit[2]==1 ):
									u_free_CG_unit = 0
									
                                                                ### [x,1,1] without flight -- go to next city if this city has one siege_cg and CG_cg unit but not flight ###
								elif ( l_TYPEofCG_Unit[1]==1 and l_TYPEofCG_Unit[2]==1 and gc.getTeam(pTID).isHasTech(t_flight)==false ):
									u_free_CG_unit = 0
									
								### choose one free CG unit ###
								if ( u_free_CG_unit == 1 ):
									if ( l_TYPEofCG_Unit[2] == 0 ):
										if ( gc.getTeam(pTID).isHasTech(gc.getInfoTypeForString("TECH_COMPOSITES"))==true ):
											u_free_CG_unit = gc.getInfoTypeForString("UNIT_MACHINE_GUN")
										elif ( gc.getTeam(pTID).isHasTech(gc.getInfoTypeForString("TECH_RAILROAD"))==true ):
											chance = CyGame().getSorenRandNum(4, "Pikeman or Maceman")
											if ( chance == 0 ):
												u_free_CG_unit = gc.getInfoTypeForString("UNIT_MACEMAN")
											else:
												u_free_CG_unit = gc.getInfoTypeForString("UNIT_PIKEMAN")
										else:
											chance = CyGame().getSorenRandNum(4, "Spearman or Axemanman")
											if ( chance == 0 ):
												u_free_CG_unit = gc.getInfoTypeForString("UNIT_AXEMAN")
											else:
												u_free_CG_unit = gc.getInfoTypeForString("UNIT_SPEARMAN")
									elif ( l_TYPEofCG_Unit[1] == 0 ):
										if ( gc.getTeam(pTID).isHasTech(t_artillery)==true ):
											u_free_CG_unit = gc.getInfoTypeForString("UNIT_ARTILLERY_CG")
										elif ( gc.getTeam(pTID).isHasTech(gc.getInfoTypeForString("TECH_STEEL"))==true ):
											u_free_CG_unit = gc.getInfoTypeForString("UNIT_SIEGEGUN")
										else:
											u_free_CG_unit = gc.getInfoTypeForString("UNIT_TREBUCHET_CG")
									elif ( l_TYPEofCG_Unit[0] == 0 and gc.getTeam(pTID).isHasTech(t_flight) == true ):
										u_free_CG_unit = gc.getInfoTypeForString("UNIT_FLAK88")
										
									### set free CG unit ###
									if ( u_free_CG_unit > 1 ):
										iX = pCity.plot().getX()
										iY = pCity.plot().getY()
										pNewUnit = pPlayer.initUnit( u_free_CG_unit, iX, iY, UnitAITypes.UNITAI_CITY_DEFENSE )
										pNewUnit.NotifyEntity(MissionTypes.MISSION_FORTIFY)
										pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_DRILL1" ), true)
										pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_DRILL2" ), true)
										pNewUnit.setLevel(6)
										pNewUnit.setName("City Guard")
										pNewUnit.setHasPromotion(p_city_guard, true)
										
																				### make sure that you dont make a city guard unit with more than 0 movement point ( with promotions ) ###
										if ( pNewUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_LIGHT1"))==true ):
											pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_LIGHT1" ), false)
										if ( pNewUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_SPEED"))==true ):
											pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_SPEED" ), false)
											
										### ausgabe ###
										cNewUnit = PyHelpers.PyInfo.UnitInfo(pNewUnit.getUnitType())
										CyInterface().addMessage(pPlayer.getID(),true,15,"",'',1,gc.getUnitInfo(u_free_CG_unit).getButton(),ColorTypes(44), iX, iY,True,True)
										CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_CITY_GUARD_GAMETXT1", (cNewUnit.getDescription(), pCity.getName())),'',0,gc.getUnitInfo(u_free_CG_unit).getButton(),ColorTypes(44), iX, iY,True,True)
										### message: %s1 City Guard in %s2 created! ###

											### CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_CITY_GUARD_UPGRADE_GAMETXT1", (cOldUnit.getDescription(), pCity.getName(), cNewUnit.getDescription())),'',0,"Art/Interface/Buttons/Promotions/freeupgrade.dds",ColorTypes(44), iX, iY,True,True)
											### message: Your %s1 City Guard in %s2 Upgraded to a %s3 ###

        #####################################################################################################################
                ####################################################################
                ### City Guard Trebuchet/Bronze Cannon/Artillery (BOMBARDIERUNG) ###
                ####################################################################
	#####################################################################################################################
			
			### check if the city has the city guard improvement ###
			for iCity in range(pPlayer.getNumCities()):
				pCity = pPlayer.getCity(iCity)
				if pCity.hasBuilding(b_city_guard):
					l_CG_bombard_units = []
					
					### check if a unit has the city guard promotion ###
					for iUnit in range(pCity.plot().getNumUnits()):
						pUnit = pCity.plot().getUnit(iUnit)
						if ( pUnit.isHasPromotion(p_city_guard) ):
							
							### check the unit with city guard promotion is a bombard unit ###
							if ( pUnit.getUnitClassType() == uc_trebuchet or pUnit.getUnitClassType() == uc_cannon or pUnit.getUnitClassType() == uc_artillery ):
								
								### remember all CG bombard units in city ###
								l_CG_bombard_units.append(pUnit)
								if ( pUnit.getUnitClassType() == uc_trebuchet ):
									ausgabe_icon = gc.getInfoTypeForString("UNIT_TREBUCHET_CG")
								elif ( pUnit.getUnitClassType() == uc_cannon ):
									ausgabe_icon = gc.getInfoTypeForString("UNIT_SIEGEGUN")
								elif ( pUnit.getUnitClassType() == uc_artillery ):
									ausgabe_icon = gc.getInfoTypeForString("UNIT_ARTILLERY_CG")
									
					### how many CG bombard units in city? ###
					nCG_units = len(l_CG_bombard_units)
					
					### check if enemy is near the city ###
					if ( nCG_units > 0 ):
						iPlotX = pCity.getX()
						iPlotY = pCity.getY()
						pPID = pPlayer.getID()
						l_iXLoop = []
						l_iYLoop = []
						
						### check the city radius plots ###
						for iXLoop in range(iPlotX - 1, iPlotX + 2, 1):
							for iYLoop in range(iPlotY - 1, iPlotY + 2, 1):
								lPlot = CyMap().plot(iXLoop, iYLoop)
								if ( lPlot.isCity()==false and lPlot.isUnit()==true ):
									if ( lPlot.isVisibleEnemyUnit(pPID)==true ):
										
                                                                                ### remember enemy plots ###
										l_iXLoop.append(iXLoop)
										l_iYLoop.append(iYLoop)
						if ( len(l_iXLoop) > 0 ):
							
							### select random enemy plot near city ###
							chance = CyGame().getSorenRandNum(len(l_iXLoop), "CG enemy plot")
							lPlot = CyMap().plot(l_iXLoop[chance], l_iYLoop[chance])
							
							### remember all enemy units on the random plot ###
							lEnemyUnits = []
							for i in range(lPlot.getNumUnits()):
								if ( lPlot.isVisibleEnemyUnit(pPID)==true ):
									lEnemyUnits.append(lPlot.getUnit(i))
									
							### let the CG bombard units attack the enemy ###
							damage = 0
							while ( nCG_units > 0 ):
								nCG_units -= 1
								for i in range(len(l_CG_bombard_units)):
									hurter = 0
									if ( l_CG_bombard_units[i].getUnitClassType() == uc_trebuchet ):
										hurter = 1
									elif ( l_CG_bombard_units[i].getUnitClassType() == uc_cannon ):
										hurter = 2
									elif ( l_CG_bombard_units[i].getUnitClassType() == uc_artillery ):
										hurter = 3
									while ( hurter > 0 ):
										hurter -= 1
											
										### random for how many damage the eunit will suffer from the attack (15 - 30) ###
										iRand_Damage = CyGame().getSorenRandNum( 16, "rand damage") + 15
											
										### random for what eUnit will suffer the damage ###
										iRand_eUnit = CyGame().getSorenRandNum(len(lEnemyUnits), "random eUnit")
										eUnit = lEnemyUnits[iRand_eUnit]
											
										### check to not kill the eUnit ###
										if ( (eUnit.getDamage() + iRand_Damage) >= 99 ):
											if ( eUnit.getDamage() <= 98 ):
												iRand_Damage = (iRand_Damage - ((eUnit.getDamage() + iRand_Damage) - 100))
											else:
												iRand_Damage = 0
											eUnit.setDamage(99, 0)
										else:
											eUnit.changeDamage(iRand_Damage, 0)
										damage = damage + (eUnit.baseCombatStr() * (iRand_Damage * 0.01))
										CyEngine().triggerEffect(gc.getInfoTypeForString("EFFECT_EXPLOSION_02"), lPlot.getPoint())

							### ausgabe ###
							if ( damage != 0 ):
								damage = int(damage)
								cityName = pCity.getName()
								CyInterface().addMessage(pPID,True,5,'','AS2D_BOMBARD',1,'Art/Interface/Buttons/actions/bombard.dds',ColorTypes(11), l_iXLoop[chance], l_iYLoop[chance], True,True)
								CyInterface().addMessage(eUnit.getOwner(),True,5,'','AS2D_BOMBARDED',1,'Art/Interface/Buttons/actions/bombard.dds',ColorTypes(11), l_iXLoop[chance], l_iYLoop[chance], True,True)
								if ( damage > 0 and damage < 1000 ):
									CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_CITY_GUARD_ZOC_GAMETXT1",(cityName,damage)),'',0,gc.getUnitInfo(ausgabe_icon).getButton(),ColorTypes(44), iPlotX, iPlotY, True,True)
										
									### message: Your Siege City Guard in %s caused a total of %d Damage to the near Enemy Units! ###
									CyInterface().addMessage(eUnit.getOwner(),false,15,CyTranslator().getText("TXT_KEY_CITY_GUARD_ZOC_GAMETXT2",(cityName,damage)),'',0,gc.getUnitInfo(ausgabe_icon).getButton(),ColorTypes(7), iPlotX, iPlotY, True,True)
									
									### message: An Enemy Siege City Guard in %s caused a total of %d Damage to our near Force! ###
								else:
									CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_CITY_GUARD_ZOC_GAMETXT3",(cityName,damage)),'',0,gc.getUnitInfo(ausgabe_icon).getButton(),ColorTypes(44), iPlotX, iPlotY, True,True)
									### message: Your Siege City Guard in %s caused Damage to the near Enemy Units! ###
										
									CyInterface().addMessage(eUnit.getOwner(),false,15,CyTranslator().getText("TXT_KEY_CITY_GUARD_ZOC_GAMETXT4",(cityName,damage)),'',0,gc.getUnitInfo(ausgabe_icon).getButton(),ColorTypes(7), iPlotX, iPlotY, True,True)
									### message: An Enemy Siege City Guard in %s caused Damage to our near Force! ###


###############################################################################################################################################
###############################################################################################################################################

        #####################################################################################################################
                                #######################
                                ### Holiday Resort  ###
                                #######################
	#####################################################################################################################
	def holidayResort(self, argsList):
		'Improvement Built'
		iImprovement, iX, iY = argsList

		
		### if there is a cottage on a coast plot, it must be from a holiday resort improvement --> build holiday village ###
		if ( iImprovement==gc.getInfoTypeForString('IMPROVEMENT_COTTAGE') ):
			pPlot = CyMap().plot(iX,iY)
			if ( pPlot.getTerrainType()==gc.getInfoTypeForString( 'TERRAIN_COAST' ) ):
				pPlayer = gc.getPlayer(pPlot.getOwner())
				CyInterface().addMessage(pPlot.getOwner(),false,25,CyTranslator().getText("TXT_KEY_NATIONAL_TRAVEL_AGENCY_GAMETXT3",()),'AS2D_DISCOVERBONUS',0,'Art/Interface/Buttons/buildings/urlaubsparadies.dds',ColorTypes(8),iX,iY,True,True)
				### message: A Holiday Resort has been created ###
				pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_JUNGLE'), 0)

###############################################################################################################################################
###############################################################################################################################################
				
	#####################################################################################################################
				####################
				### National parc###
				####################
	#####################################################################################################################
	def nationalParcImprovement(self, argsList):

		iImprovement, iX, iY = argsList
			
		if( (iImprovement==gc.getInfoTypeForString('IMPROVEMENT_NATIONALPARKL')) or (iImprovement==gc.getInfoTypeForString('IMPROVEMENT_NATIONALPARKW')) ):
			pPlot = CyMap().plot(iX,iY)
			pPlayer = gc.getPlayer(pPlot.getOwner())
			t_desert = gc.getInfoTypeForString( 'TERRAIN_DESERT' )

			### check all land plots ###
			if( (pPlot.getTerrainType()==gc.getInfoTypeForString( 'TERRAIN_TUNDRA' )) or (pPlot.getTerrainType()==gc.getInfoTypeForString( 'TERRAIN_SNOW' )) or (pPlot.getTerrainType()==gc.getInfoTypeForString( 'TERRAIN_PLAINS' )) or (pPlot.getTerrainType()==gc.getInfoTypeForString( 'TERRAIN_GRASS' )) or (pPlot.getTerrainType()==t_desert) ):

                                ### check if the land plot is no desert and place forest ###
				if ( pPlot.getTerrainType()!=t_desert ):
					pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FOREST'), 0)

                			### ausgabe1 ###
					CyInterface().addMessage(pPlot.getOwner(),false,25,CyTranslator().getText("TXT_KEY_NATIONAL_PARK_GAMETXT2",()),'AS2D_DISCOVERBONUS',0,'Art/Interface/Buttons/builds/Nationalpark_L.dds',ColorTypes(8),iX,iY,True,True)
					### message: A National Park has been created ###

                		### check if land plot is deseert and set oasis ###
				if ( pPlot.getTerrainType()==t_desert ):
					pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_OASIS'), 0)

                			### ausgabe2 (desert) ###
					CyInterface().addMessage(pPlot.getOwner(),false,25,CyTranslator().getText("TXT_KEY_NATIONAL_PARK_GAMETXT2",()),'AS2D_DISCOVERBONUS',0,'Art/Interface/Buttons/builds/Nationalpark_desert.dds',ColorTypes(8),iX,iY,True,True)
					### message: A National Park has been created ###

                		### set railroad and cottage on all land plots (if bonus on plot bonus improvement will replace cottage) ###
				pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_COTTAGE' ))
				pPlot.setRouteType(gc.getInfoTypeForString('ROUTE_RAILROAD'))

                		### check if bonus is on the land plot, if yes, set the proper improvement on the plot ###
				if( (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_ALUMINUM' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_COAL' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_COPPER' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_IRON' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_URANIUM' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_GEMS' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_GOLD' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_SILVER' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_SULPHUR' )) ):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_MINE' ))
				elif( (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_HORSE' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_COW' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_PIG' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_SHEEP' )) ):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_PASTURE' ))
				elif( (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_MARBLE' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_STONE' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_SALT' )) ):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_QUARRY' ))
				elif( pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_OIL' ) ):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_WELL' ))
				elif( (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_BANANA' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_DYE' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_INCENSE' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_SILK' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_SPICES' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_SUGAR' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_CANNABIS' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_COFFEE' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_LEMON' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_COTTON' )) ):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_PLANTATION' ))
				elif( (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_CORN' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_RICE' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_WHEAT' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_POTATO' )) ):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_FARM' ))
				elif( (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_DEER' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_FUR' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_IVORY' )) ):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_CAMP' ))
				elif(pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_WINE' )):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_WINERY' ))
				elif(pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_NATURAL_GAS' )):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_REFINERY' ))
				elif(pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_ANCIENTTEMPLE' )):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_EXPLORETEMPLE' ))

                        ### check all see plots ###
			elif( (pPlot.getTerrainType()==gc.getInfoTypeForString( 'TERRAIN_COAST' )) or (pPlot.getTerrainType()==gc.getInfoTypeForString( 'TERRAIN_OCEAN' )) ):
				pPlot.setImprovementType(-1)

                        	### check if there is a jungle on the (coast) see plot, if yes, it must be a holiday village --> set a town on the coast plot (and replace the jungle with a forest) ###
				if(pPlot.getFeatureType()==gc.getInfoTypeForString( 'FEATURE_JUNGLE' )):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_TOWN' ))

                                ### set forest on see plot ###
				pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FOREST'), 0)

                                ### check if bonus is on the see plot, if yes, set the proper improvement on the plot ###
				if( pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_OIL' ) or pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_NATURAL_GAS' ) ):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_OFFSHORE_PLATFORM' ))
				elif( (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_CLAM' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_CRAB' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_FISH' )) or (pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_PEARLS' )) ):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_FISHING_BOATS' ))					
				elif(pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_WHALE' )):
					pPlot.setImprovementType(gc.getInfoTypeForString( 'IMPROVEMENT_WHALING_BOATS' ))

                                ### ausgabe3 ###
				CyInterface().addMessage(pPlot.getOwner(),false,25,CyTranslator().getText("TXT_KEY_NATIONAL_PARK_GAMETXT2",()),'AS2D_DISCOVERBONUS',0,'Art/Interface/Buttons/builds/Nationalpark_W.dds',ColorTypes(8),iX,iY,True,True)
				### message: A National Park has been created ###

###############################################################################################################################################
###############################################################################################################################################

	#####################################################################################################################
				##############
				### Tempel ###
				##############
	#####################################################################################################################
	def tempel(self, argsList):

		iImprovement, iX, iY = argsList
		
		if(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_TAPPED_TEMPLE')):
			pPlot = CyMap().plot(iX,iY)
			if(pPlot.getBonusType(-1)==gc.getInfoTypeForString( 'BONUS_ANCIENTTEMPLE' )):
				#CyInterface().addMessage(pPlot.getOwner(),false,15,CyTranslator().getText("TXT_KEY_ANCIENT_TEMPLE_GAMETXT1",()),'',0,'Art/Interface/Buttons/worldbuilder/Atemple.dds',ColorTypes(2),iX,iY,True,True)

				### message: Ancient Temple has been explored! ###
				ibasegold = 20
				estiEnd = CyGame().getEstimateEndTurn()
				if ( estiEnd > 0 ):
					ibasegold = 70 * estiEnd / 1200
					ibasegold = int(ibasegold)

                        	### give a one time gold bonus ###
				bonus = CyGame().getSorenRandNum(ibasegold, "AncientTemple-Bonus1") + CyGame().getSorenRandNum(ibasegold, "AncientTemple-Bonus2") + ( ibasegold / 2 )
				bonus = int(bonus)
				pPlayer = gc.getPlayer(pPlot.getOwner())
				if ( pPlayer >= 0 ):
					pPlayer.changeGold(bonus)
					CyInterface().addMessage(pPlot.getOwner() ,false,15,CyTranslator().getText("TXT_KEY_ANCIENT_TEMPLE_GAMETXT2",(bonus,bonus)),'',0,'Art/Interface/Buttons/worldbuilder/Atemple.dds',ColorTypes(11),iX,iY,True,True)
					### message: Ancient Temple has been explored! %s gold discovered ###
					#CyInterface().addMessage(pPlot.getOwner() ,false,15,CyTranslator().getText("TXT_KEY_ANCIENT_TEMPLE_GAMETXT3",(CyGame().getMaxTurns(),CyGame().getMaxTurns())),'',0,'Art/Interface/Buttons/worldbuilder/Atemple.dds',ColorTypes(44),iX,iY,True,True)
					### message: %s gameturns ###


###############################################################################################################################################
###############################################################################################################################################

	#####################################################################################################################
                ####################
                ### AMPHITHEATER ###
                ####################
	#####################################################################################################################
	def amphitheater(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

        
		### filter ###
		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_AMPHITHEATER' ):
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			u_rp = gc.getInfoTypeForString("UNIT_ROME_PRAETORIAN")
			u_pr = gc.getInfoTypeForString("UNIT_PRAETORIAN_REGIMENT")
			iX = pCity.getX()
			iY = pCity.getY()
			
                	### random for what Regiment will be the Praetorian Regiment ###
			chance = CyGame().getSorenRandNum(4, "Regiment 1-4")

                	### set units with promotions and names ###
			for i in range(4):
				u_newunit = u_rp
				if ( i == chance ):
					u_newunit = u_pr
				pNewUnit = pPlayer.initUnit( u_newunit, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY )
				pNewUnit.setExperience(2, 2)
				pNewUnit.setScriptData("BUILDING_AMPHITHEATER")
				if ( i == 0 ):
					pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_COMMANDO" ), true)
					pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_BLITZ" ), true)
					pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_HEAL3" ), true)
					pNewUnit.setName("I Regiment")
				elif ( i == 1 ):
					pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CHARGE" ), true)
					pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CHARGE2" ), true)
					pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CHARGE3" ), true)
					pNewUnit.setName("II Regiment")
				elif ( i == 2 ):
					pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_AMPHIBIOUS" ), true)
					pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_MARCH" ), true)
					pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_HEAL" ), true)
					pNewUnit.setName("III Regiment")
				elif ( i == 3 ):
					pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_HERO1" ), true)
					pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_WARMTH1" ), true)
					pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_WARMTH2" ), true)
					pNewUnit.setName("IV Regiment")

                        ### ausgabe ###
			CyInterface().addMessage(CyGame().getActivePlayer(),false,15,CyTranslator().getText("TXT_KEY_AMPHITHEATRE_GAMETXT1",()),'AS2D_UNIT_BUILD_ROMAN_PRAETORIAN',0,'Art/Interface/Buttons/Units/Praetorian.dds', ColorTypes(44), -1, -1, True,True)
			### message: The Flavian Amphitheatre provides 4 Praetorians ###

###############################################################################################################################################
###############################################################################################################################################

        #####################################################################################################################
                ##################
                ### HIPPODROME ###
                ##################
	#####################################################################################################################
	def hippodrome(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		
		### filter ###
		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_HIPPODROM' ):
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			u_ewc = gc.getInfoTypeForString("UNIT_EGYPT_WARCHARIOT")
			iX = pCity.getX()
			iY = pCity.getY()

                        ### set units with promotions and names ###
			pNewUnit = pPlayer.initUnit( u_ewc, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY )
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CHARGE" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CHARGE2" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CHARGE3" ), true)
			pNewUnit.setName("War Chariot I")
			pNewUnit = pPlayer.initUnit( u_ewc, iX, iY, UnitAITypes.UNITAI_CITY_DEFENSE )
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CITY_GARRISON1" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CITY_GARRISON2" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CITY_GARRISON3" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CITY_GARRISON4" ), true)
			pNewUnit.setName("War Chariot II")
			pNewUnit = pPlayer.initUnit( u_ewc, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY )
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_ATTACK1" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_BERZERKER3" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_HEAL2" ), true)
			pNewUnit.setName("War Chariot III")
			pNewUnit = pPlayer.initUnit( u_ewc, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY )
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_BLITZ" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_AMPHIBIOUS" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_HEAL3" ), true)
			pNewUnit.setName("War Chariot IV")

                        ### ausgabe ###
			CyInterface().addMessage(CyGame().getActivePlayer(),false,15,CyTranslator().getText("TXT_KEY_HIPPODROME_GAMETXT1",()),'AS2D_UNIT_BUILD_EGYPTIAN_WAR_CHARIOT',0,'Art/Interface/Buttons/Units/Chariot_WarChariot.dds',ColorTypes(44), -1, -1, True,True)
			### message: The Hippodrome provides 4 War Chariots ###

###############################################################################################################################################
###############################################################################################################################################
			
        #####################################################################################################################
                ######################
                ### ROMAN ROADS    ###
                ######################
	#####################################################################################################################

	def romanRoads(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		
                ### filter ###
		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_ROEMERSTRASSEN' ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			pPID = pPlayer.getID()
			pTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			u_ifworker = gc.getInfoTypeForString( 'UNIT_INDIAN_FAST_WORKER' )
			p_speed = gc.getInfoTypeForString( 'PROMOTION_SPEED' )
			p_mobility = gc.getInfoTypeForString( 'PROMOTION_MOBILITY' )
			rt_road = gc.getInfoTypeForString('ROUTE_ROAD')
			rt_railroad = gc.getInfoTypeForString('ROUTE_RAILROAD')
			tt_coast = gc.getInfoTypeForString( 'TERRAIN_COAST' )
			tt_ocean = gc.getInfoTypeForString( 'TERRAIN_OCEAN' )

                        ### set units with promotions and names ###
			gc.getTeam(pTID).setHasTech(gc.getInfoTypeForString( 'TECH_ROEMERSTRASSEN' ), true, pPID, false, false)
			pNewUnit = pPlayer.initUnit( u_ifworker, iX, iY, UnitAITypes.UNITAI_WORKER )
			pNewUnit.setHasPromotion(p_speed, true)
			pNewUnit.setHasPromotion(p_mobility, true)
			pNewUnit.setName("Romen Roads Constructor I")
			pNewUnit = pPlayer.initUnit( u_ifworker, iX, iY, UnitAITypes.UNITAI_WORKER )
			pNewUnit.setHasPromotion(p_speed, true)
			pNewUnit.setHasPromotion(p_mobility, true)
			pNewUnit.setName("Romen Roads Constructor II")
			CyInterface().addMessage(CyGame().getActivePlayer(),false,15,CyTranslator().getText("TXT_KEY_ROEMERSTRASSEN_GAMETXT1",()),'AS2D_UNIT_BUILD_INDIAN_FAST_WORKER',0,'Art/Interface/Buttons/Units/FastWorker.dds',ColorTypes(44), -1, -1, True,True)
			### message: The Roman Roads provides 2 Fast Workers ###

                        ### set roads ###
			for iCity in range(pPlayer.getNumCities()):
				pCity = pPlayer.getCity(iCity)
				iiX = pCity.getX()
				iiY = pCity.getY()
				
				### mrgenie fix for the City Extended Radius
				if ( gc.getNUM_CITY_PLOTS() == 21 ):

					### check all city radius plots of all cities ###
					for iXLoop in range(iiX - 2, iiX + 3, 1):
						for iYLoop in range(iiY - 2, iiY + 3, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(pPID)==true ):
								### plot = same team? ###
								if ( lPlot.getTeam()==pTID ):
									if ( lPlot.getRouteType()!=rt_road and lPlot.getRouteType()!=rt_railroad ):
										if ( lPlot.getTerrainType()!=tt_coast and lPlot.getTerrainType()!=tt_ocean and lPlot.isPeak()==false ):
											lPlot.setRouteType(rt_road)
											CyInterface().addMessage(pPID,True,15,'','',1,'Art/Interface/Buttons/buildings/roemerstrassen.dds',ColorTypes(5), iXLoop, iYLoop,True,True)
				else: 

					### check all city radius plots of all cities ###
					for iXLoop in range(iiX - 3, iiX + 4, 1):
						for iYLoop in range(iiY - 3, iiY + 4, 1):
							lPlot = CyMap().plot(iXLoop, iYLoop)
							if ( lPlot.isPlayerCityRadius(pPID)==true ):

								### plot = same team? ###
								if ( lPlot.getTeam()==pTID ):
									if ( lPlot.getRouteType()!=rt_road and lPlot.getRouteType()!=rt_railroad ):
										if ( lPlot.getTerrainType()!=tt_coast and lPlot.getTerrainType()!=tt_ocean and lPlot.isPeak()==false ):
											lPlot.setRouteType(rt_road)
											CyInterface().addMessage(pPID,True,15,'','',1,'Art/Interface/Buttons/buildings/roemerstrassen.dds',ColorTypes(5), iXLoop, iYLoop,True,True)

###############################################################################################################################################
###############################################################################################################################################
											
        #####################################################################################################################				
                #############################################
                ### National Special Force Training Camp  ###
                #############################################
                ### NSFTC is not in the mod, instead you  ###
                ### gain these units upon military        ###
                ### acadamy creation the first time       ###
                #############################################
	#####################################################################################################################

	def NSFTCtraining(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		
                ### filter ###
		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_MILITARY_ACADEMY' ):

			PyInfo = PyHelpers.PyInfo
			### edit by mrgenie to enable units are given only once ##

			iAmountMilitaryAcadamy = 0
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			
			# Cycle through all of pPlayer's cities
			for iCityCursor in range(pPlayer.getNumCities()):
				pPlayerCity = pPlayer.getCity(iCityCursor)
				
				# If pPlayerCity is valid
				if (not pPlayerCity.isNone() and ( pPlayerCity.hasBuilding(gc.getInfoTypeForString('BUILDING_MILITARY_ACADEMY')) )):
					iAmountMilitaryAcadamy += 1
			if ( iAmountMilitaryAcadamy == 1 ):				
				# edit by mrgenie
				## original u_ans = gc.getInfoTypeForString("UNIT_AMERICAN_NAVY_SEAL")
				## original u_m = gc.getInfoTypeForString("UNIT_MARINE")			
				u_ans = gc.getInfoTypeForString("UNIT_AXEMAN")
				u_m = gc.getInfoTypeForString("UNIT_SWORDSMAN")
				p_heal3 = gc.getInfoTypeForString( "PROMOTION_HEAL3" )
				iX = pCity.getX()
				iY = pCity.getY()
				  
			
				### set units with promotions and names ###			
				for iUnitN in range(6):
					lUnitCx = []
					upgposs = 0
					if ( iUnitN == 0 ):
						pNewUnit = pPlayer.initUnit( u_ans, iX, iY, UnitAITypes.UNITAI_ATTACK )
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_SHOCK" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_SHOCK2" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_SHOCK3" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_COMBAT1" ), true)
						pNewUnit.setHasPromotion(p_heal3, true)
						## original names instead of "headcutter and Menhunter" use "Force"
						pNewUnit.setName("Ambush Special Headcutter I")
					if ( iUnitN == 1 ):
						pNewUnit = pPlayer.initUnit( u_ans, iX, iY, UnitAITypes.UNITAI_ATTACK )
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CHARGE" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CHARGE2" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CHARGE3" ), true)
						pNewUnit.setHasPromotion(p_heal3, true)
						pNewUnit.setName("Charge Special Headcutter I")                                                
					if ( iUnitN == 2 ):
						pNewUnit = pPlayer.initUnit( u_ans, iX, iY, UnitAITypes.UNITAI_ATTACK )
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_GUERILLA1" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_GUERILLA2" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_GUERILLA3" ), true)
						pNewUnit.setHasPromotion(p_heal3, true)
						pNewUnit.setName("Pinch Special Headcutter I")
					if ( iUnitN == 3 ):
						pNewUnit = pPlayer.initUnit( u_m, iX, iY, UnitAITypes.UNITAI_ATTACK )
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_SHOCK" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_SHOCK2" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_SHOCK3" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_COMBAT1" ), true)
						pNewUnit.setHasPromotion(p_heal3, true)
						pNewUnit.setName("Ambush Special Menhunter II")
					if ( iUnitN == 4 ):
						pNewUnit = pPlayer.initUnit( u_m, iX, iY, UnitAITypes.UNITAI_ATTACK )
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CHARGE" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CHARGE2" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CHARGE3" ), true)
						pNewUnit.setHasPromotion(p_heal3, true)
						pNewUnit.setName("Charge Special Menhunter II")
					if ( iUnitN == 5 ):
						pNewUnit = pPlayer.initUnit( u_m, iX, iY, UnitAITypes.UNITAI_ATTACK )
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_WOODSMAN1" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_WOODSMAN2" ), true)
						pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_DRILL1" ), true)
						pNewUnit.setHasPromotion(p_heal3, true)
						pNewUnit.setName("Pinch Special Menhunter II")

					# Check if this is the latest possible unit or if we're able to upgrade it
					for iUnitC in range(gc.getNumUnitInfos()):
						if ( pNewUnit.canUpgrade( iUnitC, True) == True ):
							cUnit = gc.getUnitInfo(iUnitC)
							if ( cUnit.getMoves() == 1 ):
								lUnitCx.append(iUnitC)
								upgposs += 1
					### if you can upgrade the base unit, upgrade it (random if more than one possible ###
					if ( upgposs > 0 ):
						iRand = CyGame().getSorenRandNum( upgposs, "Random which new Up")
						pnewUp = lUnitCx[iRand]
						pUpUnit = pPlayer.initUnit( pnewUp, iX, iY, UnitAITypes.UNITAI_ATTACK )
						pUpUnit.convert(pNewUnit)
					### if no upgrade possible, than be happy with your new unit ###
					elif ( upgposs == 0 ):
						pUpUnit = pNewUnit

					### print on screen ###
					cNewUnit = PyInfo.UnitInfo(pUpUnit.getUnitType())
					CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_NSFTC_GAMETXT1", ( pCity.getName(), cNewUnit.getDescription()) ),'',0,'art/Interface/Buttons/buildings/Stadtwache.dds',ColorTypes(44), iX, iY,True,True)
					

				### print on screen ###
				#CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_NSFTC_GAMETXT1",()),'AS2D_UNIT_BUILD_INFANTRY',0,'Art/Interface/Buttons/buildings/militaryacademy2.dds',ColorTypes(44), iX, iY,True,True)
				### message: The National Special Force Training Camp provides 3 Navy Seaals and 3 Marines ###

###############################################################################################################################################
###############################################################################################################################################
					
        #####################################################################################################################
                ##############################
                ### National Travel Agency ###
                ##############################
	#####################################################################################################################
	def nationalTravelAgency(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList
		
                ### filter ###
		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_URLAUBSPARADIES' ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			pPID = pPlayer.getID()
			pTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			u_windpark = gc.getInfoTypeForString( 'UNIT_WINDPARK' )
			tt_coast = gc.getInfoTypeForString( 'TERRAIN_COAST' )
			bt_oil = gc.getInfoTypeForString( 'BONUS_OIL' )
			bt_natural_gas = gc.getInfoTypeForString( 'BONUS_NATURAL_GAS' )
			bt_clam = gc.getInfoTypeForString( 'BONUS_CLAM' )
			bt_crab = gc.getInfoTypeForString( 'BONUS_CRAB' )
			bt_fish = gc.getInfoTypeForString( 'BONUS_FISH' )
			bt_pearls = gc.getInfoTypeForString( 'BONUS_PEARLS' )
			bt_whale = gc.getInfoTypeForString( 'BONUS_WHALE' )
			ft_forest = gc.getInfoTypeForString('FEATURE_FOREST')
			ft_jungle = gc.getInfoTypeForString( 'FEATURE_JUNGLE' )
			it_windpark = gc.getInfoTypeForString( 'IMPROVEMENT_WINDPARK' )
			it_village = gc.getInfoTypeForString( 'IMPROVEMENT_VILLAGE' )
			nUrlaubsparadies = 0

                        ### set units ###
			gc.getTeam(pTID).setHasTech(gc.getInfoTypeForString( 'TECH_URLAUBSPARADIES' ), true, pPID, false, false)
			for i in range(5):
				pPlayer.initUnit( u_windpark, iX, iY, UnitAITypes.UNITAI_WORKER )
				
        		### ausgabe1 ###
			CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_NATIONAL_TRAVEL_AGENCY_GAMETXT1",()),'AS2D_UNIT_BUILD_WORKER',0,'Art/Interface/Buttons/buildings/urlaubsparadies.dds',ColorTypes(44), iX, iY,True,True)
			### message: The National Travel Agency provides 5 Constructor/Sea ###

                	### check all city radius coast plots ###
			for iXLoop in range(iX - 2, iX + 3, 1):
				for iYLoop in range(iY - 2, iY + 3, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(pPID)==true ):
						if ( pPlot.getTeam()==pTID ):
							if ( pPlot.getTerrainType()==tt_coast ):
                                                                
                                                		### check there is no national park on the coast plot ###
								if ( pPlot.getFeatureType()!=ft_forest ):

                                                        		### check there is no wind farm on the coast plot ###
									if ( pPlot.getImprovementType()!=it_windpark ):

                                                                                ### check there is no bonus resource on the coast plot ###
										if ( pPlot.getBonusType(-1)!=bt_oil and pPlot.getBonusType(-1)!=bt_natural_gas and pPlot.getBonusType(-1)!=bt_clam and pPlot.getBonusType(-1)!=bt_crab and pPlot.getBonusType(-1)!=bt_fish and pPlot.getBonusType(-1)!=bt_pearls and pPlot.getBonusType(-1)!=bt_whale ):

                                                                                	### set holiday village(s) ###
											pPlot.setFeatureType(ft_jungle, 0)
											pPlot.setImprovementType(it_village)
											nUrlaubsparadies += 1
											CyInterface().addMessage(pPID,True,15,'','',1,'Art/Interface/Buttons/buildings/urlaubsparadies.dds',ColorTypes(8), iXLoop, iYLoop,True,True)

                                                                                        ### ausgabe2 ###
											if ( nUrlaubsparadies == 1 ):
												CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_NATIONAL_TRAVEL_AGENCY_GAMETXT2",()),'',0,'Art/Interface/Buttons/buildings/urlaubsparadies.dds',ColorTypes(8), iX, iY,True,True)
												### message: A Holiday Village has been created ###

###############################################################################################################################################
###############################################################################################################################################
					
        #####################################################################################################################
                #####################
                ### KGB (part1/2) ###
                #####################
	#####################################################################################################################
	def KGBtraining(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

                ### filter ###
		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_KGB' ):
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			u_spy = gc.getInfoTypeForString( 'UNIT_SPY' )
			iX = pCity.getX()
			iY = pCity.getY()

                        ### set units with promotions and names ###
			pNewUnit = pPlayer.initUnit( u_spy, iX, iY, UnitAITypes.UNITAI_SPY )
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( 'PROMOTION_SENTRY2' ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( 'PROMOTION_COMMANDO' ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( 'PROMOTION_SPEED' ), true)
			pNewUnit.setName("KGB Agent 001")
			pNewUnit = pPlayer.initUnit( u_spy, iX, iY, UnitAITypes.UNITAI_SPY )
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( 'PROMOTION_SENTRY2' ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( 'PROMOTION_COMMANDO' ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( 'PROMOTION_SPEED' ), true)
			pNewUnit.setName("KGB Agent 002")
			pNewUnit = pPlayer.initUnit( u_spy, iX, iY, UnitAITypes.UNITAI_SPY )
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( 'PROMOTION_SENTRY2' ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( 'PROMOTION_COMMANDO' ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( 'PROMOTION_SPEED' ), true)
			pNewUnit.setName("KGB Agent 003")

                        ### ausgabe ###
			CyInterface().addMessage(CyGame().getActivePlayer(),false,15,CyTranslator().getText("TXT_KEY_KGB_GAMETXT1",()),'',0,'Art/Interface/Buttons/Units/spy.dds',ColorTypes(44), -1, -1, True,True)
			### message: The KGB provides 3 KGB Agents ###


###############################################################################################################################################
###############################################################################################################################################
					
        #####################################################################################################################
                ################
                ### Windfarm ###
                ################
	#####################################################################################################################
	def windFarm(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

        	### filter ###
		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_WINDPARK' ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			pPID = pPlayer.getID()
			pTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			u_windpark = gc.getInfoTypeForString( 'UNIT_WINDPARK' )
			u_windparkII = gc.getInfoTypeForString( 'UNIT_WINDPARKII' )
			tt_coast = gc.getInfoTypeForString( 'TERRAIN_COAST' )
			tt_ocean = gc.getInfoTypeForString( 'TERRAIN_OCEAN' )
			bt_oil = gc.getInfoTypeForString( 'BONUS_OIL' )
			bt_natural_gas = gc.getInfoTypeForString( 'BONUS_NATURAL_GAS' )
			bt_clam = gc.getInfoTypeForString( 'BONUS_CLAM' )
			bt_crab = gc.getInfoTypeForString( 'BONUS_CRAB' )
			bt_fish = gc.getInfoTypeForString( 'BONUS_FISH' )
			bt_pearls = gc.getInfoTypeForString( 'BONUS_PEARLS' )
			bt_whale = gc.getInfoTypeForString( 'BONUS_WHALE' )
			ft_forest = gc.getInfoTypeForString('FEATURE_FOREST')
			ft_jungle = gc.getInfoTypeForString( 'FEATURE_JUNGLE' )
			it_urlaubsparadies = gc.getInfoTypeForString( 'IMPROVEMENT_URLAUBSPARADIES' )
			it_windpark = gc.getInfoTypeForString( 'IMPROVEMENT_WINDPARK' )
			nWindpark = 0

                        ### set units ###
			gc.getTeam(pTID).setHasTech(gc.getInfoTypeForString( 'TECH_WINDPARK' ), true, pPID, false, false)
			CyMap().plot(iX, iY).setImprovementType(gc.getInfoTypeForString('IMPROVEMENT_WINDPARKII'))
			for i in range(3):
				pPlayer.initUnit( u_windpark, iX, iY, UnitAITypes.UNITAI_WORKER )
			for i in range(2):
				pPlayer.initUnit( u_windparkII, iX, iY, UnitAITypes.UNITAI_WORKER )

                        ### ausgabe1 ###
			CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_WIND_FARM_GAMETXT1",()),'AS2D_UNIT_BUILD_WORKER',0,'Art/Interface/Buttons/buildings/Windpark.dds',ColorTypes(44), iX, iY,True,True)
			### message: The Wind Farm provides 3 Constructor/Sea and 2 Constructor/Land ###

                	### check all city radius coast and see plots ###
			for iXLoop in range(iX - 2, iX + 3, 1):
				for iYLoop in range(iY - 2, iY + 3, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(pPID)==true ):
						if ( pPlot.getTeam()==pTID ):
							if ( pPlot.getTerrainType()==tt_coast or pPlot.getTerrainType()==tt_ocean ):

                                                                ### check there is no national park or holiday village (or wind farm) on the (coast) see plot ###
								if ( pPlot.getFeatureType()!=ft_forest and pPlot.getFeatureType()!=ft_jungle ):
									if ( pPlot.getImprovementType()!=it_urlaubsparadies and pPlot.getImprovementType()!=it_windpark ):

                                                                                ### check there is no bonus resource on the coast plot ###
										if ( pPlot.getBonusType(-1)!=bt_oil and pPlot.getBonusType(-1)!=bt_natural_gas and pPlot.getBonusType(-1)!=bt_clam and pPlot.getBonusType(-1)!=bt_crab and pPlot.getBonusType(-1)!=bt_fish and pPlot.getBonusType(-1)!=bt_pearls and pPlot.getBonusType(-1)!=bt_whale ):
											pPlot.setImprovementType(it_windpark)
											nWindpark += 1
											CyInterface().addMessage(pPID,True,15,'','',1,'Art/Interface/Buttons/buildings/Windpark.dds',ColorTypes(9), iXLoop, iYLoop,True,True)

                                                                                        ### ausgabe2 ###
											if ( nWindpark == 1 ):
												CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_WIND_FARM_GAMETXT2",()),'',0,'Art/Interface/Buttons/buildings/Windpark.dds',ColorTypes(44), iX, iY,True,True)
												### message: A Wind Farm has been created ###

###############################################################################################################################################
###############################################################################################################################################
					
        #####################################################################################################################
                #####################
                ### National Park ###
                #####################
	#####################################################################################################################
	def nationalParcBuilding(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

                ### filter ###
		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_NATIONALPARK' ):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			pPID = pPlayer.getID()
			pTID = pPlayer.getTeam()
			iX = pCity.getX()
			iY = pCity.getY()
			u_windpark = gc.getInfoTypeForString( 'UNIT_WINDPARK' )
			u_windparkII = gc.getInfoTypeForString( 'UNIT_WINDPARKII' )
			ft_forest = gc.getInfoTypeForString('FEATURE_FOREST')
			ft_oasis = gc.getInfoTypeForString('FEATURE_OASIS')
			tt_coast = gc.getInfoTypeForString( 'TERRAIN_COAST' )
			tt_ocean = gc.getInfoTypeForString( 'TERRAIN_OCEAN' )
			tt_tundra = gc.getInfoTypeForString( 'TERRAIN_TUNDRA' )
			tt_snow = gc.getInfoTypeForString( 'TERRAIN_SNOW' )
			tt_plains = gc.getInfoTypeForString( 'TERRAIN_PLAINS' )
			tt_grass = gc.getInfoTypeForString( 'TERRAIN_GRASS' )
			tt_desert = gc.getInfoTypeForString( 'TERRAIN_DESERT' )
			it_town = gc.getInfoTypeForString( 'IMPROVEMENT_TOWN' )
			rt_railroad = gc.getInfoTypeForString('ROUTE_RAILROAD')
			bt_aluminum = gc.getInfoTypeForString( 'BONUS_ALUMINUM' )
			bt_coal = gc.getInfoTypeForString( 'BONUS_COAL' )
			bt_copper = gc.getInfoTypeForString( 'BONUS_COPPER' )
			bt_iron = gc.getInfoTypeForString( 'BONUS_IRON' )
			bt_uranium = gc.getInfoTypeForString( 'BONUS_URANIUM' )
			bt_gems = gc.getInfoTypeForString( 'BONUS_GEMS' )
			bt_gold = gc.getInfoTypeForString( 'BONUS_GOLD' )
			bt_silver = gc.getInfoTypeForString( 'BONUS_SILVER' )
			bt_sulphur = gc.getInfoTypeForString( 'BONUS_SULPHUR' )
			it_mine = gc.getInfoTypeForString( 'IMPROVEMENT_MINE' )
			bt_horse = gc.getInfoTypeForString( 'BONUS_HORSE' )
			bt_cow = gc.getInfoTypeForString( 'BONUS_COW' )
			bt_pig = gc.getInfoTypeForString( 'BONUS_PIG' )
			bt_sheep = gc.getInfoTypeForString( 'BONUS_SHEEP' )
			it_pasture = gc.getInfoTypeForString( 'IMPROVEMENT_PASTURE' )
			bt_marble = gc.getInfoTypeForString( 'BONUS_MARBLE' )
			bt_stone = gc.getInfoTypeForString( 'BONUS_STONE' )
			bt_salt = gc.getInfoTypeForString( 'BONUS_SALT' )
			it_quarry = gc.getInfoTypeForString( 'IMPROVEMENT_QUARRY' )
			bt_oil = gc.getInfoTypeForString( 'BONUS_OIL' )
			it_well = gc.getInfoTypeForString( 'IMPROVEMENT_WELL' )
			bt_banana = gc.getInfoTypeForString( 'BONUS_BANANA' )
			bt_dye = gc.getInfoTypeForString( 'BONUS_DYE' )
			bt_incense = gc.getInfoTypeForString( 'BONUS_INCENSE' )
			bt_silk = gc.getInfoTypeForString( 'BONUS_SILK' )
			bt_spices = gc.getInfoTypeForString( 'BONUS_SPICES' )
			bt_sugar = gc.getInfoTypeForString( 'BONUS_SUGAR' )
			bt_cannabis = gc.getInfoTypeForString( 'BONUS_CANNABIS' )
			bt_coffee = gc.getInfoTypeForString( 'BONUS_COFFEE' )
			bt_lemon = gc.getInfoTypeForString( 'BONUS_LEMON' )
			bt_cotton = gc.getInfoTypeForString( 'BONUS_COTTON' )
			it_plantation = gc.getInfoTypeForString( 'IMPROVEMENT_PLANTATION' )
			bt_corn = gc.getInfoTypeForString( 'BONUS_CORN' )
			bt_rice = gc.getInfoTypeForString( 'BONUS_RICE' )
			bt_wheat = gc.getInfoTypeForString( 'BONUS_WHEAT' )
			bt_potato = gc.getInfoTypeForString( 'BONUS_POTATO' )
			it_farm = gc.getInfoTypeForString( 'IMPROVEMENT_FARM' )
			bt_deer = gc.getInfoTypeForString( 'BONUS_DEER' )
			bt_fur = gc.getInfoTypeForString( 'BONUS_FUR' )
			bt_ivory = gc.getInfoTypeForString( 'BONUS_IVORY' )
			it_camp = gc.getInfoTypeForString( 'IMPROVEMENT_CAMP' )
			bt_wine = gc.getInfoTypeForString( 'BONUS_WINE' )
			it_winery = gc.getInfoTypeForString( 'IMPROVEMENT_WINERY' )
			bt_natural_gas = gc.getInfoTypeForString( 'BONUS_NATURAL_GAS' )
			it_refinery = gc.getInfoTypeForString( 'IMPROVEMENT_REFINERY' )
			bt_temple = gc.getInfoTypeForString( 'BONUS_ANCIENTTEMPLE' )
			it_explore_temple = gc.getInfoTypeForString( 'IMPROVEMENT_EXPLORETEMPLE' )
			nNationalpark = 0

                        ### set units ###
			gc.getTeam(pTID).setHasTech(gc.getInfoTypeForString( 'TECH_NATIONALPARK' ), true, pPID, false, false)
			#CyMap().plot(iX, iY).setFeatureType(ft_forest, 0)
			for i in range(2):
				pPlayer.initUnit( u_windpark, iX, iY, UnitAITypes.UNITAI_WORKER )
			for i in range(3):
				pPlayer.initUnit( u_windparkII, iX, iY, UnitAITypes.UNITAI_WORKER )

                        ### ausgabe1 ###
			CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_NATIONAL_PARK_GAMETXT1",()),'AS2D_UNIT_BUILD_WORKER',0,'art/Interface/Buttons/terrainfeatures/forestevergreen.dds',ColorTypes(44), iX, iY,True,True)
			### message: The National Park provides 2 Constructor/Sea and 3 Constructor/Land ###

                        ### check the 8 surrounding plots arround the city plot and set national park on all land plots ###
			for iXLoop in range(iX - 1, iX + 2, 1):
				for iYLoop in range(iY - 1, iY + 2, 1):
					pPlot = CyMap().plot(iXLoop, iYLoop)
					if ( pPlot.isPlayerCityRadius(pPID)==true ):
						if ( pPlot.getTeam()==pTID ):
							if ( pPlot.getTerrainType()!=tt_coast and pPlot.getTerrainType()!=tt_ocean and pPlot.isPeak()==false ):
								if( (pPlot.getTerrainType()==tt_tundra) or (pPlot.getTerrainType()==tt_snow) or (pPlot.getTerrainType()==tt_plains) or (pPlot.getTerrainType()==tt_grass) or (pPlot.getTerrainType()==tt_desert) ):
									if ( pPlot.getTerrainType()!=tt_desert ):
										pPlot.setFeatureType(ft_forest, 0)

                                                                                ### ausgabe2 ###
										CyInterface().addMessage(pPID,True,15,'','',1,'Art/Interface/Buttons/builds/Nationalpark_L.dds',ColorTypes(8), iXLoop, iYLoop,True,True)
									if ( pPlot.getTerrainType()==tt_desert ):
										pPlot.setFeatureType(ft_oasis, 0)

                                                                                ### ausgabe3 (desert) ###
										CyInterface().addMessage(pPID,True,15,'','',1,'Art/Interface/Buttons/builds/Nationalpark_desert.dds',ColorTypes(8), iXLoop, iYLoop,True,True)
									pPlot.setImprovementType(it_town)
									pPlot.setRouteType(rt_railroad)
									if( (pPlot.getBonusType(-1)==bt_aluminum) or (pPlot.getBonusType(-1)==bt_coal) or (pPlot.getBonusType(-1)==bt_copper) or (pPlot.getBonusType(-1)==bt_iron) or (pPlot.getBonusType(-1)==bt_uranium) or (pPlot.getBonusType(-1)==bt_gems) or (pPlot.getBonusType(-1)==bt_gold) or (pPlot.getBonusType(-1)==bt_silver) or (pPlot.getBonusType(-1)==bt_sulphur) ):
										pPlot.setImprovementType(it_mine)
									elif( (pPlot.getBonusType(-1)==bt_horse) or (pPlot.getBonusType(-1)==bt_cow) or (pPlot.getBonusType(-1)==bt_pig) or (pPlot.getBonusType(-1)==bt_sheep) ):
										pPlot.setImprovementType(it_pasture)
									elif( (pPlot.getBonusType(-1)==bt_marble) or (pPlot.getBonusType(-1)==bt_stone) or (pPlot.getBonusType(-1)==bt_salt) ):
										pPlot.setImprovementType(it_quarry)
									elif( pPlot.getBonusType(-1)==bt_oil ):
										pPlot.setImprovementType(it_well)
									elif( (pPlot.getBonusType(-1)==bt_banana) or (pPlot.getBonusType(-1)==bt_dye) or (pPlot.getBonusType(-1)==bt_incense) or (pPlot.getBonusType(-1)==bt_silk) or (pPlot.getBonusType(-1)==bt_spices) or (pPlot.getBonusType(-1)==bt_sugar) or (pPlot.getBonusType(-1)==bt_cannabis) or (pPlot.getBonusType(-1)==bt_coffee) or (pPlot.getBonusType(-1)==bt_lemon) or (pPlot.getBonusType(-1)==bt_cotton) ):
										pPlot.setImprovementType(it_plantation)
									elif( (pPlot.getBonusType(-1)==bt_corn) or (pPlot.getBonusType(-1)==bt_rice) or (pPlot.getBonusType(-1)==bt_wheat) or (pPlot.getBonusType(-1)==bt_potato) ):
										pPlot.setImprovementType(it_farm)
									elif( (pPlot.getBonusType(-1)==bt_deer) or (pPlot.getBonusType(-1)==bt_fur) or (pPlot.getBonusType(-1)==bt_ivory) ):
										pPlot.setImprovementType(it_camp)
									elif(pPlot.getBonusType(-1)==bt_wine):
										pPlot.setImprovementType(it_winery)
									elif(pPlot.getBonusType(-1)==bt_natural_gas):
										pPlot.setImprovementType(it_refinery)
									elif(pPlot.getBonusType(-1)==bt_temple):
										pPlot.setImprovementType(it_explore_temple)
									nNationalpark += 1

                                                                        ### ausgabe4 ###
									if ( nNationalpark == 1 ):
										CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_NATIONAL_PARK_GAMETXT2",()),'',0,'art/Interface/Buttons/terrainfeatures/forestevergreen.dds',ColorTypes(8), iX, iY,True,True)
										### message: A National Park has been created ###


###############################################################################################################################################
###############################################################################################################################################
					
        #####################################################################################################################
                ##################################
                ### Leonardo Wonder (part 3/3) ###
                ##################################
	#####################################################################################################################
	def leonardoWonderBuilding(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

                ### filter ###
		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_LEONARDOS_WORKSHOP' ):
			u_mechine_gun = gc.getInfoTypeForString("UNIT_MACHINE_GUN")
			p_city_garrison1 = gc.getInfoTypeForString("PROMOTION_CITY_GARRISON1")
			p_defence1 = gc.getInfoTypeForString("PROMOTION_DEFENCE1")
			p_stalwart1 = gc.getInfoTypeForString("PROMOTION_STALWART1")
			p_stalwart2 = gc.getInfoTypeForString("PROMOTION_STALWART2")
			p_stalwart3 = gc.getInfoTypeForString("PROMOTION_STALWART3")
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			pP_ID = pPlayer.getID()
			py = PyHelpers.PyPlayer(pP_ID)
			lpUnit = []
			lpUnitPosX = []
			lpUnitPosY = []
			lpnewUp = []
			up_pro_game = 0

                        ### get the unit list of the player ###
			for pUnit in py.getUnitList():

                        	### 20% chance for every unit ###
				chance = CyGame().getSorenRandNum(5, "Leonardo built fUp chance")
				if ( chance == 0 ):
					lUnitCx = []

                                	### look if unit can be upgraded, if yes --> upgrade remember possibility -> lUnitCx list ###
					for iUnitC in range(gc.getNumUnitInfos()):
						if ( pUnit.canUpgrade( iUnitC, true) == true ):
							lUnitCx.append(iUnitC)

                                        ### choose a random upgrade for the pUnit if more than one possible --> lpnewUp list ###
					if ( len(lUnitCx) >= 1 ):

                                                ### dont upgrade units without defencive promotions to machine gun (but possible upgrade for units with lvl 1) ###
						pass_up = false
						if ( len(lUnitCx)==1 ):
							if ( lUnitCx[0]!=u_mechine_gun ):
								pass_up = true
							elif ( pUnit.getLevel()<=1 ):
								pass_up = true
							elif ( lUnitCx[0]==u_mechine_gun ):
								if ( pUnit.isHasPromotion(p_city_garrison1)==true or pUnit.isHasPromotion(p_defence1)==true or pUnit.isHasPromotion(p_stalwart1)==true or pUnit.isHasPromotion(p_stalwart2)==true or pUnit.isHasPromotion(p_stalwart3)==true ):
									pass_up = true
							#if ( pUnit.baseCombatStr() > lUnitCx[0].baseCombatStr() ):
							#	pass_up = false
						elif ( len(lUnitCx)>=2 ):
							new_lUnitCx = lUnitCx
							for i in range(len(lUnitCx)):
								if ( lUnitCx[i]==u_mechine_gun ):
									if ( pUnit.getLevel()>=2 ):
										if ( pUnit.isHasPromotion(p_city_garrison1)==false and pUnit.isHasPromotion(p_defence1)==false and pUnit.isHasPromotion(p_stalwart1)==false and pUnit.isHasPromotion(p_stalwart2)==false and pUnit.isHasPromotion(p_stalwart3)==false ):

                                                                                        ### create new list without mechine gun ###
											new_lUnitCx = []
											for ii in range(len(lUnitCx)):
												if ( lUnitCx[ii]!=u_mechine_gun ):
													new_lUnitCx.append(lUnitCx[ii])
							lUnitCx = new_lUnitCx
							pass_up = true

						if ( pass_up == true ):
							iRand = CyGame().getSorenRandNum( len(lUnitCx), "Random which new Up")
							pnewUp = lUnitCx[iRand]

                                                        ### original unit list ###
							lpUnit.append(pUnit)

                                                        ### upgrade unit list ###
							lpnewUp.append(pnewUp)
							up_pro_game += 1
							lpUnitPosX.append(pUnit.getX())
							lpUnitPosY.append(pUnit.getY())

                        ### look if there is a unit to upgrade ###
			if ( up_pro_game > 0 ):
				PyInfo = PyHelpers.PyInfo
				for i in range(up_pro_game):
					pUnit = lpUnit[i]
					pnewUp = lpnewUp[i]
					iiX = lpUnitPosX[i]
					iiY = lpUnitPosY[i]
					pPlot = CyMap().plot(iiX,iiY)

                                        ### upgrade all units in the lpUnit unit list to lpnewUp list units (all units in city or forts) ###
					if ( (pPlot.isCity()==true) or (pPlot.getImprovementType()==gc.getInfoTypeForString("IMPROVEMENT_FORT")) ):
						pNewUnit = pPlayer.initUnit( pnewUp, iiX, iiY, UnitAITypes.NO_UNITAI )
						pNewUnit.convert(pUnit)

                                                ### look if the unit was a musketeman with musket promotion and take it away ###
						if ( pNewUnit.getUnitClassType() != gc.getInfoTypeForString("UNITCLASS_MUSKETMAN") ):
							if ( pNewUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_MUSKETE"))==true ):
								pNewUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_MUSKETE"), false)
						pNewUnit.finishMoves()

                                                ### ausgabe ###
						cUnit = PyInfo.UnitInfo(pUnit.getUnitType())
						ccUnit = PyInfo.UnitInfo(pNewUnit.getUnitType())
						CyInterface().addMessage(pP_ID,true,25,'','',1,'Art/Interface/Buttons/promotions/freeupgrade.dds',ColorTypes(11),iiX,iiY,True,True)
						CyInterface().addMessage(pP_ID,false,25,CyTranslator().getText("TXT_KEY_LEONARDO_WONDER_GAMETXT1",(cUnit.getDescription(), ccUnit.getDescription())),'AS2D_UNIT_BUILD_UNIQUE_UNIT',0,'Art/Interface/Buttons/promotions/freeupgrade.dds',ColorTypes(11),iiX,iiY,True,True)
						### message: Your %s upgraded to a %s ###

                                        ### all units in lpUnit list not in city or fort get a free upgrade promotion ###
					if ( (pPlot.isCity()==false) and (pPlot.getImprovementType()!=gc.getInfoTypeForString("IMPROVEMENT_FORT")) ):
						pUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_FREEUPGRADE"), true)

                                                ### ausgabe ###
						cheroUnit = PyInfo.UnitInfo(pUnit.getUnitType())
						CyInterface().addMessage(pP_ID,true,25,'','',1,'Art/Interface/Buttons/promotions/freeupgrade.dds',ColorTypes(11),iiX,iiY,True,True)
						CyInterface().addMessage(pP_ID,false,25,CyTranslator().getText("TXT_KEY_LEONARDO_WONDER_GAMETXT2",(cheroUnit.getDescription(),cheroUnit.getDescription())),'',0,'Art/Interface/Buttons/promotions/freeupgrade.dds',ColorTypes(11),iiX,iiY,True,True)
						### message: Your %s gained a Free Upgrade Promotion ###

###############################################################################################################################################
###############################################################################################################################################
					
        #####################################################################################################################
                ##################
                ### City Guard ###
                ##################
	#####################################################################################################################
	def cityGuardTraining(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

                ### filter ###
		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_STADTWACHE' ):

			PyInfo = PyHelpers.PyInfo
			iX = pCity.getX()
			iY = pCity.getY()
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			u_warrior = gc.getInfoTypeForString( 'UNIT_WARRIOR' )

                        ### base unit ###
			pNewUnit = pPlayer.initUnit( u_warrior, iX, iY, UnitAITypes.UNITAI_CITY_DEFENSE )
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_DRILL1" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_DRILL2" ), true)
			pNewUnit.setLevel(6)
			pNewUnit.setName("City Guard")
			pNewUnit.NotifyEntity(MissionTypes.MISSION_FORTIFY)

                        ### check if you can upgrade the base unit ###
			lUnitCx = []
			upgposs = 0
			for iUnitC in range(gc.getNumUnitInfos()):
				if ( pNewUnit.canUpgrade( iUnitC, True) == True ):
					cUnit = gc.getUnitInfo(iUnitC)
					if ( cUnit.getMoves() == 1 ):
						lUnitCx.append(iUnitC)
						upgposs += 1

                        ### if you can upgrade the base unit, upgrade it (random if more than one possible ###
			if ( upgposs > 0 ):
				iRand = CyGame().getSorenRandNum( upgposs, "Random which new Up")
				pnewUp = lUnitCx[iRand]
				pUpUnit = pPlayer.initUnit( pnewUp, iX, iY, UnitAITypes.UNITAI_CITY_DEFENSE )
				pUpUnit.convert(pNewUnit)

                        ### if no upgrade possible, than be happy with your warrior ###
			elif ( upgposs == 0 ):
				pUpUnit = pNewUnit

                        ### place the no-movement promotion (place it at the end, else with 0 movement points you cant upgrade the base unit) ###
			pUpUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_CITY_GUARD" ), true)

                        ### make sure that you dont make a city guard unit with more than 0 movement point ( with promotions ) ###
			if ( pUpUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_LIGHT1"))==true ):
				pUpUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_LIGHT1" ), false)
			if ( pUpUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_SPEED"))==true ):
				pUpUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_SPEED" ), false)

                        ### ausgabe ###
			cNewUnit = PyInfo.UnitInfo(pUpUnit.getUnitType())
			CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_CITY_GUARD_GAMETXT1", (cNewUnit.getDescription(), pCity.getName())),'',0,'art/Interface/Buttons/buildings/Stadtwache.dds',ColorTypes(44), iX, iY,True,True)
			### message: %s1 City Guard in %s2 created ###

###############################################################################################################################################
###############################################################################################################################################
					
        #####################################################################################################################
                ########################
                ### Tallest Building ###
                ########################
	#####################################################################################################################
	def tallestBuilding(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

                ### filter ###
		b_tb = gc.getInfoTypeForString( 'BUILDING_TALLEST_BUILDING' )
		if iBuildingType == b_tb:
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			pPID = pPlayer.getID()
			pCityName = pCity.getName()
			iX = pCity.getX()
			iY = pCity.getY()
			nb_tb = False

			### check for old tallest building wonder ###
			for iPlayer in range(gc.getMAX_PLAYERS()):

				if ( nb_tb ):
					break
				
				ppPlayer = gc.getPlayer(iPlayer)
				if ((ppPlayer.isAlive()) or (ppPlayer.isBarbarian())):
					for iCity in range(ppPlayer.getNumCities()):
						ppCity = ppPlayer.getCity(iCity)
						ippCityName = ppCity.getName()
						if ppCity.hasBuilding(b_tb):

                                                        ### make sure you dont delete the new tallest building ###
							if ( pCityName != ippCityName ):

                                                                ### delete the old tallest building #####deleted by mrgenie, because AI keeps building this wonder, in the xml the limit can be set!
								#ppCity.setHasRealBuilding(b_tb,0)
								ppCityName = ippCityName
								ppCivName = ppPlayer.getCivilizationDescription(0)
								iiX = ppCity.getX()
								iiY = ppCity.getY()
								nb_tb = True
								break

                        ### the new owner of the tallest building wonder get a 5% one time cultur bonus in the owner city (5% of the city culture) ###
			pCC = pCity.getCulture(pPID)
			pCC = pCC / 20
			pCity.changeCulture(pPID, pCC, true)

                        ### ausgabe ###
			CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_TALLEST_BUILDING_GAMETXT1",(pCC, pCityName)),'',0,'art/Interface/Buttons/buildings/cntower.dds',ColorTypes(24), -1, -1,True,True)
			### message: The Tallest Building added %d Culture to %s ###
#			CyInterface().addMessage(CyGame().getActivePlayer(),true,15,CyTranslator().getText("TXT_KEY_TALLEST_BUILDING_GAMETXT2",(pCityName, pPlayer.getCivilizationDescription(0))),'',0,'art/Interface/Buttons/buildings/cntower.dds',ColorTypes(44), iX, iY, True,True)

			### message: In %s the %s constructed the Worlds Tallest Building ###
#			if ( nb_tb != 0 ):
#				CyInterface().addMessage(CyGame().getActivePlayer(),True,15,CyTranslator().getText("TXT_KEY_TALLEST_BUILDING_GAMETXT3",(ppCityName, ppCivName)),'',0,'art/Interface/Buttons/buildings/cntower.dds',ColorTypes(7), iiX, iiY, True,True)
				### message: The Tall Building in %s (%s) isn't the Worlds Tallest Building anymore. ###
			if not ( nb_tb ):
				popupInfo = CyPopupInfo()
				popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
				popupInfo.setData1(iBuildingType)
				popupInfo.setData2(pCity.getID())
				popupInfo.setData3(0)
				popupInfo.setText(u"showWonderMovie")
				popupInfo.addPopup(pCity.getOwner())

###############################################################################################################################################
###############################################################################################################################################
					
        #####################################################################################################################
                ##########################
                ### CRUSADE WONDER 1/2 ###
                ##########################
	#####################################################################################################################
	def CrusadeWonderBuilding(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

		### filter ###
		if iBuildingType == gc.getInfoTypeForString("BUILDING_CRUSADE"):

			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			u_templar = gc.getInfoTypeForString("UNIT_KNIGHT_TEMPLAR")
			u_knight = gc.getInfoTypeForString("UNIT_KNIGHT")
			b_obelisk = gc.getInfoTypeForString("BUILDING_OBELISK")
			iX = pCity.getX()
			iY = pCity.getY()
			pPID = pPlayer.getID()
			pCityName = pCity.getName()
			state_Religion = pPlayer.getStateReligion()
			lb_reliBuild = []

                        ### free Units with promotions and names ###
			pNewUnit = pPlayer.initUnit( u_templar, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY )
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_MARCH" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_HEAL3" ), true)
			pNewUnit.setName("1st Holy Corps")
			pNewUnit = pPlayer.initUnit( u_templar, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY )
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_MARCH" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_HEAL2" ), true)
			pNewUnit.setName("2nd Holy Corps")
			pNewUnit = pPlayer.initUnit( u_templar, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY )
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_MARCH" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_HEAL" ), true)
			pNewUnit.setName("3rd Holy Corps")
			pNewUnit = pPlayer.initUnit( u_knight, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY )
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_MARCH" ), true)
			pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_BLITZ" ), true)
			pNewUnit.setName("1st Holy Squadron")

                        ### free Buildings ###
			if ( not pCity.hasBuilding(b_obelisk) or pCity.isFreeBuilding(b_obelisk)==true):
				pCity.setHasRealBuilding(b_obelisk,1)
				lb_reliBuild.append(b_obelisk)
			if ( state_Religion != gc.getInfoTypeForString("NO_RELIGION") ):
				if ( state_Religion == gc.getInfoTypeForString("RELIGION_JUDAISM") ):
					b_temple = gc.getInfoTypeForString("BUILDING_JEWISH_TEMPLE")
					b_cathedral = gc.getInfoTypeForString("BUILDING_JEWISH_CATHEDRAL")
					b_monastery = gc.getInfoTypeForString("BUILDING_JEWISH_MONASTERY")
				elif ( state_Religion == gc.getInfoTypeForString("RELIGION_CHRISTIANITY") ):
					b_temple = gc.getInfoTypeForString("BUILDING_CHRISTIAN_TEMPLE")
					b_cathedral = gc.getInfoTypeForString("BUILDING_CHRISTIAN_CATHEDRAL")
					b_monastery = gc.getInfoTypeForString("BUILDING_CHRISTIAN_MONASTERY")
				elif ( state_Religion == gc.getInfoTypeForString("RELIGION_ISLAM") ):
					b_temple = gc.getInfoTypeForString("BUILDING_ISLAMIC_TEMPLE")
					b_cathedral = gc.getInfoTypeForString("BUILDING_ISLAMIC_CATHEDRAL")
					b_monastery = gc.getInfoTypeForString("BUILDING_ISLAMIC_MONASTERY")
				elif ( state_Religion == gc.getInfoTypeForString("RELIGION_HINDUISM") ):
					b_temple = gc.getInfoTypeForString("BUILDING_HINDU_TEMPLE")
					b_cathedral = gc.getInfoTypeForString("BUILDING_HINDU_CATHEDRAL")
					b_monastery = gc.getInfoTypeForString("BUILDING_HINDU_MONASTERY")
				elif ( state_Religion == gc.getInfoTypeForString("RELIGION_BUDDHISM") ):
					b_temple = gc.getInfoTypeForString("BUILDING_BUDDHIST_TEMPLE")
					b_cathedral = gc.getInfoTypeForString("BUILDING_BUDDHIST_CATHEDRAL")
					b_monastery = gc.getInfoTypeForString("BUILDING_BUDDHIST_MONASTERY")
				elif ( state_Religion == gc.getInfoTypeForString("RELIGION_CONFUCIANISM") ):
					b_temple = gc.getInfoTypeForString("BUILDING_CONFUCIAN_TEMPLE")
					b_cathedral = gc.getInfoTypeForString("BUILDING_CONFUCIAN_CATHEDRAL")
					b_monastery = gc.getInfoTypeForString("BUILDING_CONFUCIAN_MONASTERY")
				elif ( state_Religion == gc.getInfoTypeForString("RELIGION_TAOISM") ):
					b_temple = gc.getInfoTypeForString("BUILDING_TAOIST_TEMPLE")
					b_cathedral = gc.getInfoTypeForString("BUILDING_TAOIST_CATHEDRAL")
					b_monastery = gc.getInfoTypeForString("BUILDING_TAOIST_MONASTERY")
				if ( not pCity.hasBuilding(b_temple) ):
					pCity.setHasRealBuilding(b_temple,1)
					lb_reliBuild.append(b_temple)
				if ( not pCity.hasBuilding(b_cathedral) ):
					pCity.setHasRealBuilding(b_cathedral,1)
					lb_reliBuild.append(b_cathedral)
				if ( not pCity.hasBuilding(b_monastery) ):
					pCity.setHasRealBuilding(b_monastery,1)
					lb_reliBuild.append(b_monastery)

                        ### ausgabe ###
			if ( len(lb_reliBuild) > 0 ):
				if ( len(lb_reliBuild) == 1 ):
					bname_b0 = PyHelpers.PyInfo.BuildingInfo(lb_reliBuild[0]).getDescription()
					CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_CRUSADE_WONDER_GAMETXT2",(pCityName, bname_b0)),'',0,'Art/Interface/Buttons/buildings/crusade.dds',ColorTypes(44), iX, iY, True,True)
					### message: In %s the Crusade Wonder provides a free %s ###
				elif ( len(lb_reliBuild) == 2 ):
					bname_b0 = PyHelpers.PyInfo.BuildingInfo(lb_reliBuild[0]).getDescription()
					bname_b1 = PyHelpers.PyInfo.BuildingInfo(lb_reliBuild[1]).getDescription()
					CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_CRUSADE_WONDER_GAMETXT3",(pCityName, bname_b0, bname_b1)),'',0,'Art/Interface/Buttons/buildings/crusade.dds',ColorTypes(44), iX, iY, True,True)
					### message: In %s the Crusade Wonder provides a free %s and %s ###
				elif ( len(lb_reliBuild) == 3 ):
					bname_b0 = PyHelpers.PyInfo.BuildingInfo(lb_reliBuild[0]).getDescription()
					bname_b1 = PyHelpers.PyInfo.BuildingInfo(lb_reliBuild[1]).getDescription()
					bname_b2 = PyHelpers.PyInfo.BuildingInfo(lb_reliBuild[2]).getDescription()
					CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_CRUSADE_WONDER_GAMETXT4",(pCityName, bname_b0, bname_b1, bname_b2)),'',0,'Art/Interface/Buttons/buildings/crusade.dds',ColorTypes(44), iX, iY, True,True)
					### message: In %s the Crusade Wonder provides a free %s, %s and %s ###
				elif ( len(lb_reliBuild) == 4 ):
					bname_b0 = PyHelpers.PyInfo.BuildingInfo(lb_reliBuild[0]).getDescription()
					bname_b1 = PyHelpers.PyInfo.BuildingInfo(lb_reliBuild[1]).getDescription()
					bname_b2 = PyHelpers.PyInfo.BuildingInfo(lb_reliBuild[2]).getDescription()
					bname_b3 = PyHelpers.PyInfo.BuildingInfo(lb_reliBuild[3]).getDescription()
					CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_CRUSADE_WONDER_GAMETXT5",(pCityName, bname_b0, bname_b1, bname_b2, bname_b3)),'',0,'Art/Interface/Buttons/buildings/crusade.dds',ColorTypes(44), iX, iY, True,True)
					### message: In %s the Crusade Wonder provides a free %s, %s, %s and %s ###

			CyInterface().addMessage(pPID,false,15,CyTranslator().getText("TXT_KEY_CRUSADE_WONDER_GAMETXT1",(pCityName,pCityName)),'',0,'Art/Interface/Buttons/Units/knight_templar.dds',ColorTypes(44), iX, iY, True,True)

			#CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_CRUSADE_WONDER_GAMETXT1",(pCityName)),'',0,'Art/Interface/Buttons/Units/knight_templar.dds',ColorTypes(44), iX, iY, True,True)
			### message: In %s the Crusade Wonder provides free Crusade Units ###

                        ### negative side effects ###
			### -1 global population in xml file / in addition to that if pCity >= 15 than -1 population in pCity ###
			if ( pCity.getPopulation() >= 15 ):
				pCity.changePopulation(-1)

###############################################################################################################################################
###############################################################################################################################################
					
        #####################################################################################################################
                ######################
                ### ARTOFARTILLERY ###
                ######################
	#####################################################################################################################
	def artOfArtillery(self, argsList):
		'Building Completed'
		pCity, iBuildingType = argsList

        	### filter ###
		if iBuildingType == gc.getInfoTypeForString( 'BUILDING_ARTOFARTILLERY' ):
			pPlayer = gc.getPlayer(pCity.plot().getOwner())
			u_bronze_cannon = gc.getInfoTypeForString("UNIT_BOMBARD")
			iX = pCity.getX()
			iY = pCity.getY()

                	### set units with promotion ###
			for i in range(2):
				pNewUnit = pPlayer.initUnit( u_bronze_cannon, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY )
				pNewUnit.setHasPromotion(gc.getInfoTypeForString( "PROMOTION_HEAL" ), true)
				pNewUnit.setExperience(1, 2)

			### ausgabe ###
			CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_ARTOFARTILLERY_GAMETXT1",()),'',0,'Art/Interface/Buttons/Units/bombard.dds',ColorTypes(44), iX, iY, True,True)
			### message: The Art Of Artillery provides 2 free Bronze Cannons! ###

###############################################################################################################################################
###############################################################################################################################################

        #####################################################################################################################
                ############################################################
                ### SPHINX give FREE UPGRADE promotion (to max 10 units) ###
                ############################################################
	#####################################################################################################################
	def sphinxFreePromotion(self, argsList):
		'Unit Completed'

		pCity = argsList[0]
		pUnit = argsList[1]
		pPlayer = gc.getPlayer(pUnit.plot().getOwner())
		pTID = pPlayer.getTeam()


		### filter (to increase late game performance) ###
		if ( gc.getTeam(pTID).isHasTech(gc.getInfoTypeForString("TECH_RIFLING")) == false ):
			if ( pUnit.canAcquirePromotionAny() ):
				
				### look for sphinx wonder ###
				if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_SPHINX'))==true ):
					p_freeup = gc.getInfoTypeForString("PROMOTION_FREEUPGRADE")
					v_freeup = 0
					
                                	### get the unit list of the player ###
					for ppUnit in PyHelpers.PyPlayer(pPlayer.getID()).getUnitList():
                                                
                                        	### check how many units already have the free upgrade promotion... ###
						if ( ppUnit.isHasPromotion(p_freeup)==true ):
							v_freeup += 1
							
                                	### ...if less 10, give the pUnit the free upgrade promotion ###
					if ( v_freeup < 10 ):
						pUnit.setHasPromotion(p_freeup, true)
						
                                        	### ausgabe ###
						CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_SPHINX_WONDER_GAMETXT1",(pCity.getName(),PyHelpers.PyInfo.UnitInfo(pUnit.getUnitType()).getDescription())),'',0,'Art/Interface/Buttons/promotions/freeupgrade.dds',ColorTypes(11), pCity.getX(), pCity.getY(),True,True)

						### message: In %s the Sphinx Wonder provides a free Upgrade Promotion to your new build %s! ###

###############################################################################################################################################
###############################################################################################################################################

        #####################################################################################################################
                ###########################################################
                ### mounted units free formation promotion from STABLES ###
                ###########################################################
	#####################################################################################################################
	def stablesFreePromotion(self, argsList):
		'Unit Completed'

		pCity = argsList[0]
		pUnit = argsList[1]
		pPlayer = gc.getPlayer(pUnit.plot().getOwner())
		pTID = pPlayer.getTeam()

                ### filter (to increase late game performance) ###
		if ( gc.getTeam(pTID).isHasTech(gc.getInfoTypeForString("TECH_ASSEMBLY_LINE")) == False ):
			if ( pUnit.canAcquirePromotionAny() ):
                                
                                ### look for stables ###
				if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_SCYTHIA_STABLES'))== True or pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_NUBIAN_STABLES'))== True ):
					if ( pUnit.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_MOUNTED") ):
						if ( pUnit.isHasPromotion(gc.getInfoTypeForString( 'PROMOTION_FLANKING1' )) == True ):
							pUnit.setHasPromotion(gc.getInfoTypeForString( 'PROMOTION_FLANKING1' ), False )

###############################################################################################################################################
###############################################################################################################################################

        #####################################################################################################################
                ####################################################################
                ### free Muskete Promotion with Musket Manufactory ###
                ####################################################################
	#####################################################################################################################
	def musketFactoryFreePromotion(self, argsList):
		'Unit Completed'

		pCity = argsList[0]
		pUnit = argsList[1]
		pPlayer = gc.getPlayer(pUnit.plot().getOwner())

		if ( pUnit.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_MUSKETMAN") ):
			if pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_MUSKET_MANUFAKTUR')):
				if pCity.hasBonus(gc.getInfoTypeForString("BONUS_SULPHUR")):
					pUnit.setHasPromotion(gc.getInfoTypeForString("PROMOTION_MUSKETE"), True)
					CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_MUSKET_MANUFACTURE_GAMETXT1",(pCity.getName(),PyHelpers.PyInfo.UnitInfo(pUnit.getUnitType()).getDescription())),'',0,'Art/Interface/Buttons/promotions/muskete.dds',ColorTypes(44), pCity.getX(), pCity.getY(),True,True)
					### message: In %s the Musket Manufacture provides a free Musket Promotion to your new build %s! ###

###############################################################################################################################################
###############################################################################################################################################

        #####################################################################################################################
                #####################
                ### KGB (part2/2) ###
                #####################
	#####################################################################################################################
	def KGBfreeSpyPromotion(self, argsList):
		'Unit Completed'

		
		pCity = argsList[0]
		pUnit = argsList[1]
		pPlayer = gc.getPlayer(pUnit.plot().getOwner())

                ### filter ###
		if ( pUnit.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_SPY") ):

                        ### check all cities ###
			for iCity in range(pPlayer.getNumCities()):
				pCity = pPlayer.getCity(iCity)

                                ### if the player have the kgb wonder give all new build spies the sentry II promotion ###
				if pCity.hasBuilding(gc.getInfoTypeForString( 'BUILDING_KGB' )):
					pUnit.setHasPromotion(gc.getInfoTypeForString( 'PROMOTION_SENTRY2' ), true)
					CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_KGB_GAMETXT2",(pCity.getName(),PyHelpers.PyInfo.UnitInfo(pUnit.getUnitType()).getDescription())),'',0,'Art/Interface/Buttons/promotions/Sentry2.dds',ColorTypes(44), pCity.getX(), pCity.getY(),True,True)
					### message: In %s the KGB Wonder provides a free Sentry II Promotion to your new build %s! ###

###############################################################################################################################################
###############################################################################################################################################

        #####################################################################################################################
                #########################################################
                ### City Guard free Promotion on Unit creation chance ###
                #########################################################
	#####################################################################################################################
	def cityGuardFreePromotion(self, argsList):
		'Unit Completed'

		pCity = argsList[0]
		pUnit = argsList[1]
		pPlayer = gc.getPlayer(pUnit.plot().getOwner())
		pTID = pPlayer.getTeam()
		b_sw = gc.getInfoTypeForString('BUILDING_STADTWACHE')

                ### filter ###
		if ( pCity.hasBuilding(b_sw) == True and pUnit.canAcquirePromotionAny()):
			#chance = 0

                	### only look here if you dont have a golden age ###
			if ( pPlayer.isGoldenAge() == False ):
				rand_fp = 42

                        	### 50% chance filter ###
				chance = CyGame().getSorenRandNum(2, "Random_1 if free prom yes/no")
				if ( chance == 0 ):

                                	### set the base chance for the free promotion to 1/20 (5%) - that means without golden age you have now a 1/2 * 1/20 chance = 1/40 (2.5%) ###
                                	### 2.5% minimum chance ###
					rand_fp = 20
					
                                	### now you can increase your base chance with military buildings in your cities up to 8.3% --> 1/2 * 1/6 = 1/12 = 8.3% chance for free promotion ###
        				###Specialist###
# Not in Visa				if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_MILITARYACADEMY')) ):
#						rand_fp = rand_fp - 5

        				###City Improvements###
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_BARRACKS')) ):
						rand_fp = rand_fp - 5
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_CASTLE')) ):
						rand_fp = rand_fp - 3
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_DRYDOCK')) ):
						rand_fp = rand_fp - 1
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_SCYTHIA_STABLES')) or pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_NUBIAN_STABLES')) ):
						rand_fp = rand_fp - 1
						
        				###National Wonders###
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_HEROIC_EPIC')) ):
						rand_fp = rand_fp - 3
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_WEST_POINT')) ):
						rand_fp = rand_fp - 3
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_MILITARY_ACADEMY')) ):
						rand_fp = rand_fp - 5
# Not in Visa				if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_LOCKHEED')) ):
#						rand_fp = rand_fp - 2
# Not in Visa				if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_RAYTHEON')) ):
#						rand_fp = rand_fp - 2
# Not in Visa				if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_FAIRCHILD')) ):
#						rand_fp = rand_fp - 2
						
        				###World Wonders###
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_ARTOFWAR')) ):
						rand_fp = rand_fp - 3
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_PENTAGON')) ):
						rand_fp = rand_fp - 1
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_HIPPODROM')) ):
						rand_fp = rand_fp - 1
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_AMPHITHEATER')) ):
						rand_fp = rand_fp - 2
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_ARTOFARTILLERY')) ):
						rand_fp = rand_fp - 1
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_STATUE_OF_ZEUS')) ):
						rand_fp = rand_fp - 2
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_ARTEMIS')) ):
						rand_fp = rand_fp - 2
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_SPHINX')) ):
						rand_fp = rand_fp - 1
					if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_CRUSADE')) ):
						rand_fp = rand_fp - 3
                                        ### ~8% maximum chance (1/2 * 1/6 = 1/12 =~ 8,33...%) ###
						
                                	### Maximal Chance ###
					if ( rand_fp <=6 ):
						rand_fp = 6

                	### if you have golden age, forget all the crap above and look here ###
			else:
				
				### free promotion chance with golden age = 100% ###
				rand_fp = 1

			#CyInterface().addMessage(pPlayer.getID(),True,45,"chance%d rand%d" %(chance, rand_fp),'',1,'',ColorTypes(8), -1, -1,True,True)
			### is 42 if no golden age and 50% chance (filter) is NO --> that means no free promotion, im so sorry ###
			if ( rand_fp != 42):

				### random chance with the rand_fp number  (100% with golden age; 2% till 7% without golden age) ###
				chance = CyGame().getSorenRandNum(rand_fp, "Random_2 if free prom yes/no")

				#CyInterface().addMessage(pPlayer.getID(),True,45,"chance%d rand%d" %(chance, rand_fp),'',1,'',ColorTypes(8), -1, -1,True,True)
				if ( chance == 0 ):
	
					### loop until you found a proper promotion for this unit (that means freeprom1 != 0) ###
					freeprom1 = 0
					while (freeprom1 == 0):

						### choose one of the 47 possible promotion thingies ###
						chance = CyGame().getSorenRandNum(47, "Random welche free prom")

						uct = pUnit.getUnitCombatType()
						uctNaval = gc.getInfoTypeForString("UNITCOMBAT_NAVAL")
						uctRecon = gc.getInfoTypeForString("UNITCOMBAT_RECON")
						freeprom2 = 0
						freeprom3 = 0
						freeprom4 = 0
						freeprom5 = 0

		#################################################################################################
		# WOODSMAN / GUERILLA / WARMTH / COLD / AMPHIBIOUS / COMMANDO / BLITZ / CITY GARRISON / DEFENCE #
		#################################################################################################
						if ( (chance >= 0) and (chance <= 16) ):
							iForestJungle = 0
							iHillPeak = 0
							iDesert = 0
							iTundraSnow = 0
							iUnits = 0
							### --- ###
							#iRiver = 0
							#iEnemyCityw = 0
							#iEnemyCity = 0
							#inotFriendlyCityw = 0
							#inotFriendlyCity = 0
							### --- ###
							lTerraFeatureT = []
							iTerraFeatureTn = 0			
							iPlotX = pCity.getX()
							iPlotY = pCity.getY()
							pPID = pPlayer.getID()
							#pTID = pPlayer.getTeam()

                                                        ### check the city radius plots ###
							for iXLoop in range(iPlotX - 2, iPlotX + 3, 1):
								for iYLoop in range(iPlotY - 2, iPlotY + 3, 1):
									lPlot = CyMap().plot(iXLoop, iYLoop)
									if ( lPlot.isPlayerCityRadius(pPID)==true ):

										if ( (uct != uctNaval) ):

                                                                                        ### remember all the different plots/features/enemy units/cities within the city radius ###
                                                                                        # WOODSMAN (part1/2) #
											if ( lPlot.getFeatureType()==gc.getInfoTypeForString("FEATURE_FOREST") or lPlot.getFeatureType()==gc.getInfoTypeForString("FEATURE_JUNGLE") ):
												lTerraFeatureT.append(0)
												iTerraFeatureTn += 1
												iForestJungle += 1

                                                                                        # GUERILLA (part1/2) #
											if ( lPlot.isPeak()==true or lPlot.isHills()==true ):
												lTerraFeatureT.append(1)
												iTerraFeatureTn += 1
												iHillPeak += 1

                                                                                        # WARMTH (part1/2) #
											if lPlot.getTerrainType()==gc.getInfoTypeForString("TERRAIN_DESERT"):
												lTerraFeatureT.append(2)
												iTerraFeatureTn += 1
												iDesert += 1

                                                                                        # COLD (part1/2) #
											if ( lPlot.getTerrainType()==gc.getInfoTypeForString("TERRAIN_TUNDRA") or lPlot.getTerrainType()==gc.getInfoTypeForString("TERRAIN_SNOW") ):
												lTerraFeatureT.append(3)
												iTerraFeatureTn += 1
												iTundraSnow += 1

                                                                                	# AMPHIBIOUS (part1/2) #
											if ( lPlot.isRiver()==true ):
												if ( (uct != uctRecon) ):
													lTerraFeatureT.append(4)
													iTerraFeatureTn += 1
													#iRiver += 1

										# COMMANDO / BLITZ (part1/3) #
										if ( lPlot.isEnemyCity(pTID)==true ):
											for i in range(2):
												lTerraFeatureT.append(5)
												lTerraFeatureT.append(6)
												iTerraFeatureTn += 2
											#	iEnemyCityw += 2
											#iEnemyCity += 1

										# COMMANDO / BLITZ (part2/3) #
										if ( lPlot.isCity()==true and lPlot.isFriendlyCity(pTID)==false ):
											lTerraFeatureT.append(5)
											lTerraFeatureT.append(6)
											iTerraFeatureTn += 2
											#inotFriendlyCityw += 2
											#inotFriendlyCity += 1

										# CITY GARRISON (part1/2) #
										if ( lPlot.isCity()==false and lPlot.isUnit()==true ):
											uctRecon = gc.getInfoTypeForString("UNITCOMBAT_RECON")
											uctArcher = gc.getInfoTypeForString("UNITCOMBAT_ARCHER")
											uctMelee = gc.getInfoTypeForString("UNITCOMBAT_MELEE")
											uctGun = gc.getInfoTypeForString("UNITCOMBAT_GUN")
											uctArmor = gc.getInfoTypeForString("UNITCOMBAT_ARMOR")
				
											if ( (uct == uctRecon) or (uct == uctArcher) or (uct == uctMelee) or (uct == uctGun) or (uct == uctArmor) ):
												if ( lPlot.isVisibleEnemyUnit(pPID)==true ):
													for i in range(lPlot.getNumUnits()):
														iUnits += 1
														for ii in range(6):
															lTerraFeatureT.append(7)
															iTerraFeatureTn += 1

										# DEFENCE (part1/2) #
										if ( lPlot.isCity()==false and lPlot.isUnit()==true ):
											if ( lPlot.isVisibleEnemyUnit(pPID)==true ):
												for i in range(lPlot.getNumUnits()):
													iUnits += 1
													lTerraFeatureT.append(8)
													iTerraFeatureTn += 1


							#CyInterface().addMessage(pPlayer.getID(),True,45,"(f%d h%d d%d s%d r%d) e(%d %d) e/n(%d %d) eUnits%d" %(iForestJungle, iHillPeak, iDesert, iTundraSnow, iRiver, iEnemyCityw, iEnemyCity, inotFriendlyCityw, inotFriendlyCity, iUnits),'',1,'',ColorTypes(5), -1, -1,True,True)
							if ( iTerraFeatureTn > 0 ):

                                                		### rmore is a chance value - rmore=1 means a 100% chance to get the main promotion (xxxx1 e.g. woodsman1) and the next higher level of the promotion (xxx1 + xxx2 e.g woodsman1+2) ###
                                                		### base rmore value = 4 --> 1/4= 25% ###
                                                        	### you can increase the rmore chance with certain buildings/more certain plots in the city radius/more enemy units in the city radius/... (see all the promotions below) ###
								rmore = 4
								iRand = CyGame().getSorenRandNum( iTerraFeatureTn, "Random for Terra/Feature")
								TerraFeatureT = lTerraFeatureT[iRand]
								if ( (uct != uctNaval) ):

                                                                	# WOODSMAN (part2/2) #
									if ( TerraFeatureT == 0 ):
										freeprom1 = gc.getInfoTypeForString("PROMOTION_WOODSMAN1")
										pUnit.setHasPromotion(freeprom1, true)
										if ( iForestJungle>=9 ):
											rmore = 3
										if ( iForestJungle>=12 ):
											rmore = 2
										chance2 = CyGame().getSorenRandNum(rmore, "Random for Woodsman 1 + 2")
										if ( chance2==0 and iForestJungle>=3 ):
											freeprom2 = gc.getInfoTypeForString("PROMOTION_WOODSMAN2")
											pUnit.setHasPromotion(freeprom2, true)
											chance3 = CyGame().getSorenRandNum(rmore, "Random for Woodsman 1 + 2 + 3")
											if ( chance3==0 and iForestJungle>=6 ):
												freeprom3 = gc.getInfoTypeForString("PROMOTION_WOODSMAN3")
												pUnit.setHasPromotion(freeprom3, true)

                                                                	# GUERILLA (part2/2) #
									if ( TerraFeatureT == 1 ):
										freeprom1 = gc.getInfoTypeForString("PROMOTION_GUERILLA1")
										pUnit.setHasPromotion(freeprom1, true)
										if ( iHillPeak>=9 ):
											rmore = 3
										if ( iHillPeak>=12 ):
											rmore = 2
										chance2 = CyGame().getSorenRandNum(rmore, "Random for Guerilla 1 + 2")
										if ( chance2==0 and iHillPeak>=3 ):
											freeprom2 = gc.getInfoTypeForString("PROMOTION_GUERILLA2")
											pUnit.setHasPromotion(freeprom2, true)
											chance3 = CyGame().getSorenRandNum(rmore, "Random for Guerilla 1 + 2 + 3")
											if ( chance3==0 and iHillPeak>=6 ):
												freeprom3 = gc.getInfoTypeForString("PROMOTION_GUERILLA3")
												pUnit.setHasPromotion(freeprom3, true)

                                                                	# WARMTH (part2/2) #
									if ( TerraFeatureT == 2 ):
										freeprom1 = gc.getInfoTypeForString("PROMOTION_WARMTH1")
										pUnit.setHasPromotion(freeprom1, true)
										if ( iDesert>=6 ):
											rmore = 3
										if ( iDesert>=9 ):
											rmore = 2
										chance2 = CyGame().getSorenRandNum(rmore, "Random for Warmth 1 + 2")
										if ( chance2==0 and iDesert>=3 ):
											freeprom2 = gc.getInfoTypeForString("PROMOTION_WARMTH2")
											pUnit.setHasPromotion(freeprom2, true)

                                                                	# COLD (part2/2) #
									if ( TerraFeatureT == 3 ):
										freeprom1 = gc.getInfoTypeForString("PROMOTION_COLD1")
										pUnit.setHasPromotion(freeprom1, true)
										if ( iTundraSnow>=6 ):
											rmore = 3
										if ( iTundraSnow>=9 ):
											rmore = 2
										chance2 = CyGame().getSorenRandNum(rmore, "Random for Cold 1 + 2")
										if ( chance2==0 and iTundraSnow>=4 ):
											freeprom2 = gc.getInfoTypeForString("PROMOTION_COLD2")
											pUnit.setHasPromotion(freeprom2, true)

                                                                        # AMPHIBIOUS (part2/2) #
									if ( TerraFeatureT == 4 ):
										if ( (uct != uctRecon) ):
											freeprom1 = gc.getInfoTypeForString("PROMOTION_AMPHIBIOUS")
											pUnit.setHasPromotion(freeprom1, true)

                                                                        # COMMANDO (part3/3) #
									if ( TerraFeatureT == 5 ):
										freeprom1 = gc.getInfoTypeForString("PROMOTION_COMMANDO")
										pUnit.setHasPromotion(freeprom1, true)

                                                                # BLITZ (part3/3) #
								if ( TerraFeatureT == 6 ):
									if ( uct != uctRecon ):
										freeprom1 = gc.getInfoTypeForString("PROMOTION_BLITZ")
										pUnit.setHasPromotion(freeprom1, true)

                                                                # rmore: CITY GARRISON / DEFENCE #
								if ( TerraFeatureT == 7 or TerraFeatureT == 8 ):

                                                                        ### more units means higher chance for more and higher lvl promotions ###
									rmore = 10
									if ( iUnits >= 1 ):
										rmore = 9
									if ( iUnits >= 2 ):
										rmore = 8
									if ( iUnits >= 3 ):
										rmore = 7
									if ( iUnits >= 10 ):
										rmore = 4
									if ( iUnits >= 20 ):
										rmore = 3
									if ( iUnits >= 30 ):
										rmore = 2

                                                                # CITY GARRISON (part2/2) #
								if ( TerraFeatureT == 7 ):
									freeprom1 = gc.getInfoTypeForString("PROMOTION_CITY_GARRISON1")
									pUnit.setHasPromotion(freeprom1, true)
									chance2 = CyGame().getSorenRandNum(rmore, "Random for City Garrision 1 + 2")
									if ( chance2 == 0 ):
										freeprom2 = gc.getInfoTypeForString("PROMOTION_CITY_GARRISON2")
										pUnit.setHasPromotion(freeprom2, true)
										chance3 = CyGame().getSorenRandNum(rmore, "Random for City Garrision 1 + 2 + 3")
										if ( chance3 == 0 ):
											freeprom3 = gc.getInfoTypeForString("PROMOTION_CITY_GARRISON3")
											pUnit.setHasPromotion(freeprom3, true)
											chance4 = CyGame().getSorenRandNum(rmore, "Random for City Garrision 1 + 2 + 3 + 4")
											if ( chance4 == 0 ):
												freeprom4 = gc.getInfoTypeForString("PROMOTION_CITY_GARRISON4")
												pUnit.setHasPromotion(freeprom4, true)

                                                                # DEFENCE (part2/2) #
								if ( TerraFeatureT == 8 ):
									freeprom1 = gc.getInfoTypeForString("PROMOTION_DEFENCE1")
									pUnit.setHasPromotion(freeprom1, true)
									chance2 = CyGame().getSorenRandNum(rmore, "Random for Defence1 + 2")
									if ( chance2 == 0 ):
										freeprom2 = gc.getInfoTypeForString("PROMOTION_DEFENCE2")
										pUnit.setHasPromotion(freeprom2, true)
										chance3 = CyGame().getSorenRandNum(rmore, "Random for Defence1 + 2 + 3")
										if ( chance3 == 0 ):
											freeprom3 = gc.getInfoTypeForString("PROMOTION_DEFENCE3")
											pUnit.setHasPromotion(freeprom3, true)
											chance4 = CyGame().getSorenRandNum(rmore, "Random for Defence1 + 2 + 3 + 4")
											if ( chance4 == 0 ):
												freeprom4 = gc.getInfoTypeForString("PROMOTION_DEFENCE4")
												pUnit.setHasPromotion(freeprom4, true)
		#########
		# MEDIC #
		#########
						if ( chance == 17 ):
							freeprom1 = gc.getInfoTypeForString("PROMOTION_MEDIC1")
							pUnit.setHasPromotion(freeprom1, true)
							chance2 = CyGame().getSorenRandNum(10, "Random for Medic 1 + 2")
							if ( chance2 >= 8 ):
								freeprom2 = gc.getInfoTypeForString("PROMOTION_MEDIC2")
								pUnit.setHasPromotion(freeprom2, true)
								if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_HOSPITAL')) ):
									chance3 = CyGame().getSorenRandNum(10, "Random for Medic 1 + 2 + 3")
									if ( chance3 == 1 ):
										freeprom3 = gc.getInfoTypeForString("PROMOTION_MEDIC3")
										pUnit.setHasPromotion(freeprom3, true)
		########
		# HEAL #
		########
						if ( chance == 18 ):
							freeprom1 = gc.getInfoTypeForString("PROMOTION_HEAL")
							pUnit.setHasPromotion(freeprom1, true)
							chance2 = CyGame().getSorenRandNum(10, "Random for Heal 1 + 2")
							if ( chance2 == 1 ):
								freeprom2 = gc.getInfoTypeForString("PROMOTION_HEAL2")
								pUnit.setHasPromotion(freeprom2, true)
								if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_HOSPITAL')) ):
									chance3 = CyGame().getSorenRandNum(10, "Random for Heal 1 + 2 + 3")
									if ( chance3 == 1 ):
										freeprom3 = gc.getInfoTypeForString("PROMOTION_HEAL3")
										pUnit.setHasPromotion(freeprom3, true)
		#######################
		# MARCH (+AMPHIBIOUS) #
		#######################
						if ( chance == 19 ):
							freeprom1 = gc.getInfoTypeForString("PROMOTION_MARCH")
							pUnit.setHasPromotion(freeprom1, true)
							if ( (uct != uctRecon) and (uct != uctNaval) ):
								chance2 = CyGame().getSorenRandNum(10, "Random for AMPHIBIOUS")
								if ( chance2 >= 8 ):
									freeprom2 = gc.getInfoTypeForString("PROMOTION_AMPHIBIOUS")
									pUnit.setHasPromotion(freeprom2, true)
		############
		# MOBILITY #
		############

						if ( chance == 20 ):							
							if ( pUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_CITY_GUARD"))==false ):
								uctHeli = gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER")
								if ( (uct != uctNaval) and (uct != uctHeli) ):
									freeprom1 = gc.getInfoTypeForString("PROMOTION_MOBILITY")
									pUnit.setHasPromotion(freeprom1, true)
					
		#########
		# SPEED #
		#########
						if ( chance == 21 ):
							if ( pUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_CITY_GUARD"))==false ):
								freeprom1 = gc.getInfoTypeForString("PROMOTION_SPEED")
								pUnit.setHasPromotion(freeprom1, true)
		##############
		# NAVIGATION #
		##############
						if ( chance == 22 ):
							if (  uct == uctNaval ):
								freeprom1 = gc.getInfoTypeForString("PROMOTION_NAVIGATION1")
								pUnit.setHasPromotion(freeprom1, true)
								if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_HARBOR')) ):
									chance2 = CyGame().getSorenRandNum(10, "Random for Navigation 1 + 2")
									if ( chance2 >= 8 ):
										freeprom2 = gc.getInfoTypeForString("PROMOTION_NAVIGATION2")
										pUnit.setHasPromotion(freeprom2, true)
		##########
		# SENTRY #
		##########
						if ( chance == 23 ):
							freeprom1 = gc.getInfoTypeForString("PROMOTION_SENTRY")
							pUnit.setHasPromotion(freeprom1, true)
							rmore = 10
							if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_SCOTLAND_YARD')) ):
								rmore = rmore - 2
							if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_KGB')) ):
								rmore = rmore - 2
							chance2 = CyGame().getSorenRandNum(rmore, "Random for Sentry 1 + 2")
							if ( chance2 == 0 ):
								freeprom2 = gc.getInfoTypeForString("PROMOTION_SENTRY2")
								pUnit.setHasPromotion(freeprom2, true)
								chance3 = CyGame().getSorenRandNum(rmore, "Random for Sentry 1 + 2 + 3")
								if ( chance3 == 0 ):
									freeprom3 = gc.getInfoTypeForString("PROMOTION_SENTRY3")
									pUnit.setHasPromotion(freeprom3, true)
		############
		# FLANKING #
		############
						if ( chance == 24 ):
							freeprom1 = gc.getInfoTypeForString("PROMOTION_FLANKING1")
							pUnit.setHasPromotion(freeprom1, true)
							chance2 = CyGame().getSorenRandNum(10, "Random for Flanking 1 + 2")
							if ( chance2 >= 8 ):
								freeprom2 = gc.getInfoTypeForString("PROMOTION_FLANKING2")
								pUnit.setHasPromotion(freeprom2, true)
								chance3 = CyGame().getSorenRandNum(10, "Random for Flanking 1 + 2 + 3")
								if ( chance3 == 1 ):
									freeprom3 = gc.getInfoTypeForString("PROMOTION_FLANKING3")
									pUnit.setHasPromotion(freeprom3, true)
		#########
		# DRILL #
		#########
						if ( chance == 25 ):
							freeprom1 = gc.getInfoTypeForString("PROMOTION_DRILL1")
							pUnit.setHasPromotion(freeprom1, true)
							rmore = 5
							if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_ARTEMIS')) ):
								rmore = rmore - 3
							chance2 = CyGame().getSorenRandNum(rmore, "Random for Drill 1 + 2")
							if ( chance2 == 0 ):
								freeprom2 = gc.getInfoTypeForString("PROMOTION_DRILL2")
								pUnit.setHasPromotion(freeprom2, true)
								chance3 = CyGame().getSorenRandNum(rmore, "Random for Drill 1 + 2 + 3")
								if ( chance3 == 0 ):
									freeprom3 = gc.getInfoTypeForString("PROMOTION_DRILL3")
									pUnit.setHasPromotion(freeprom3, true)
									chance4 = CyGame().getSorenRandNum(rmore, "Random for Drill 1 + 2 + 3 + 4")
									if ( chance4 == 0 ):
										freeprom4 = gc.getInfoTypeForString("PROMOTION_DRILL4")
										pUnit.setHasPromotion(freeprom4, true)
										chance5 = CyGame().getSorenRandNum(rmore, "Random for Drill 1 + 2 + 3 + 4 + 5")
										if ( chance5 == 0 ):
											freeprom5 = gc.getInfoTypeForString("PROMOTION_DRILL5")
											pUnit.setHasPromotion(freeprom5, true)
		#######################
		# BARRAGE (+ACCURACY) #
		#######################

						if ( chance == 26 ):
							uctSiege = gc.getInfoTypeForString("UNITCOMBAT_SIEGE")
							uctArmor = gc.getInfoTypeForString("UNITCOMBAT_ARMOR")
							uctArcher = gc.getInfoTypeForString("UNITCOMBAT_ARCHER")					
							if ( (uct == uctNaval) or (uct == uctSiege) or (uct == uctArmor) or (uct == uctArcher) ):
								if ( (pUnit.getUnitType()!=gc.getInfoTypeForString("UNIT_SUBMARINE")) and (pUnit.getUnitType()!=gc.getInfoTypeForString("UNIT_NUCLEAR_SUBMARINE")) ):
									freeprom1 = gc.getInfoTypeForString("PROMOTION_BARRAGE1")
									pUnit.setHasPromotion(freeprom1, true)
									rmore = 10
									if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_ARTOFARTILLERY')) ):
										rmore = rmore - 4
									if ( (uct == uctNaval) or (uct == uctSiege) ):
										chance2 = CyGame().getSorenRandNum(rmore, "Random for Accuracy 1")
										if ( chance2 == 0 ):
											freeprom2 = gc.getInfoTypeForString("PROMOTION_ACCURACY")
											pUnit.setHasPromotion(freeprom2, true)
									if ( uct != uctArcher ):
										chance2 = CyGame().getSorenRandNum(rmore - 2, "Random for Barrage 1 + 2")
										if ( chance2 == 0 ):
											freeprom3 = gc.getInfoTypeForString("PROMOTION_BARRAGE2")
											pUnit.setHasPromotion(freeprom3, true)
											chance3 = CyGame().getSorenRandNum(rmore, "Random for Barrage 1 + 2 + 3")
											if ( chance3 == 0 ):
												freeprom4 = gc.getInfoTypeForString("PROMOTION_BARRAGE3")
												pUnit.setHasPromotion(freeprom4, true)
												chance4 = CyGame().getSorenRandNum(rmore, "Random for Barrage 1 + 2 + 3 + 4")
												if ( chance4 == 0 ):
													freeprom5 = gc.getInfoTypeForString("PROMOTION_BARRAGE4")
													pUnit.setHasPromotion(freeprom5, true)
						
		#######################
		# ACCURACY (+BARRAGE) #
		#######################
						
						if ( chance == 27 ):
							uctSiege = gc.getInfoTypeForString("UNITCOMBAT_SIEGE")
							if ( (uct == uctNaval) or (uct == uctSiege) ):
								if ( (pUnit.getUnitType()!=gc.getInfoTypeForString("UNIT_SUBMARINE")) and (pUnit.getUnitType()!=gc.getInfoTypeForString("UNIT_NUCLEAR_SUBMARINE")) ):
									freeprom1 = gc.getInfoTypeForString("PROMOTION_ACCURACY")
									pUnit.setHasPromotion(freeprom1, true)
									rmore = 5
									if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_ARTOFARTILLERY')) ):
										rmore = rmore - 3
									chance2 = CyGame().getSorenRandNum(rmore, "Random for Accuracy 1 + 2 / Barrage 1")
									if ( chance2 == 0 ):
										freeprom2 = gc.getInfoTypeForString("PROMOTION_ACCURACY2")
										pUnit.setHasPromotion(freeprom2, true)
									if ( chance2 == 1 ):
										freeprom3 = gc.getInfoTypeForString("PROMOTION_BARRAGE1")
										pUnit.setHasPromotion(freeprom3, true)
						
		#########
		# SHOCK #
		#########                                                
						if ( chance == 28 ):
							uctArcher = gc.getInfoTypeForString("UNITCOMBAT_ARCHER")
							uctMelee = gc.getInfoTypeForString("UNITCOMBAT_MELEE")
							uctMounted = gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")
							uctSiege = gc.getInfoTypeForString("UNITCOMBAT_SIEGE")
							if ( (uct == uctMelee) or (uct == uctArcher) or (uct == uctMounted) or (uct == uctSiege) ):
								freeprom1 = gc.getInfoTypeForString("PROMOTION_SHOCK")
								pUnit.setHasPromotion(freeprom1, true)
								rmore = 5
								if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_CASTLE')) ):
									rmore = rmore - 1
								chance2 = CyGame().getSorenRandNum(rmore, "Random for Shock 1 + 2")
								if ( chance2 == 0 ):
									freeprom2 = gc.getInfoTypeForString("PROMOTION_SHOCK2")
									pUnit.setHasPromotion(freeprom2, true)
									chance3 = CyGame().getSorenRandNum(rmore + 1, "Random for Shock 1 + 2 + 3")
									if ( chance3 == 0 ):
										freeprom3 = gc.getInfoTypeForString("PROMOTION_SHOCK3")
										pUnit.setHasPromotion(freeprom3, true)
		#########
		# COVER #
		#########
						if ( chance == 29 ):
							uctMelee = gc.getInfoTypeForString("UNITCOMBAT_MELEE")
							uctMounted = gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")
							uctArcher = gc.getInfoTypeForString("UNITCOMBAT_ARCHER")
							uctGun = gc.getInfoTypeForString("UNITCOMBAT_GUN")
							if ( (uct == uctMelee) or (uct == uctMounted) or (uct == uctArcher) or (uct == uctGun) ):
								freeprom1 = gc.getInfoTypeForString("PROMOTION_COVER")
								pUnit.setHasPromotion(freeprom1, true)
								rmore = 5
								if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_WALLS')) ):
									rmore = rmore - 1
								chance2 = CyGame().getSorenRandNum(rmore, "Random for Cover 1 + 2")
								if ( chance2 == 0 ):
									freeprom2 = gc.getInfoTypeForString("PROMOTION_COVER2")
									pUnit.setHasPromotion(freeprom2, true)
									chance3 = CyGame().getSorenRandNum(rmore + 1, "Random for Cover 1 + 2 + 3")
									if ( chance3 == 0 ):
										freeprom3 = gc.getInfoTypeForString("PROMOTION_COVER3")
										pUnit.setHasPromotion(freeprom3, true)
		#############
		# FORMATION #
		#############
						if ( chance == 30 ):
							uctMelee = gc.getInfoTypeForString("UNITCOMBAT_MELEE")
							uctMounted = gc.getInfoTypeForString("UNITCOMBAT_MOUNTED")
							uctGun = gc.getInfoTypeForString("UNITCOMBAT_GUN")
							uctArcher = gc.getInfoTypeForString("UNITCOMBAT_ARCHER")
							if ( (uct == uctMelee) or (uct == uctMounted) or (uct == uctGun) or (uct == uctArcher) ):
								freeprom1 = gc.getInfoTypeForString("PROMOTION_FORMATION")
								pUnit.setHasPromotion(freeprom1, true)
								rmore = 5
								if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_WALLS')) ):
									rmore = rmore - 1
								chance2 = CyGame().getSorenRandNum(rmore, "Random for Formation 1 + 2")
								if ( chance2 == 0 ):
									freeprom2 = gc.getInfoTypeForString("PROMOTION_FORMATION2")
									pUnit.setHasPromotion(freeprom2, true)
									chance3 = CyGame().getSorenRandNum(rmore + 1, "Random for Formation 1 + 2 + 3")
									if ( chance3 == 0 ):
										freeprom3 = gc.getInfoTypeForString("PROMOTION_FORMATION3")
										pUnit.setHasPromotion(freeprom3, true)
		##########
		# CHARGE #
		##########
						if ( chance == 31 ):
							if ( (uct != uctNaval) ):
								freeprom1 = gc.getInfoTypeForString("PROMOTION_CHARGE")
								pUnit.setHasPromotion(freeprom1, true)
								rmore = 4
								if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_CASTLE')) ):
									rmore = rmore - 1
								chance2 = CyGame().getSorenRandNum(rmore, "Random for Charge 1 + 2")
								if ( chance2 == 0 ):
									freeprom2 = gc.getInfoTypeForString("PROMOTION_CHARGE2")
									pUnit.setHasPromotion(freeprom2, true)
									chance3 = CyGame().getSorenRandNum(rmore + 1, "Random for Charge 1 + 2 + 3")
									if ( chance3 == 0 ):
										freeprom3 = gc.getInfoTypeForString("PROMOTION_CHARGE3")
										pUnit.setHasPromotion(freeprom3, true)
		#########
		# PINCH #
		#########
						if ( chance == 32 ):
							if ( (uct != uctNaval) ):
								freeprom1 = gc.getInfoTypeForString("PROMOTION_PINCH")
								pUnit.setHasPromotion(freeprom1, true)
								rmore = 5
								if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_MUSKET_MANUFAKTUR')) ):
									rmore = rmore - 1
								chance2 = CyGame().getSorenRandNum(rmore, "Random for Pinch 1 + 2")
								if ( chance2 == 0 ):
									freeprom2 = gc.getInfoTypeForString("PROMOTION_PINCH2")
									pUnit.setHasPromotion(freeprom2, true)
									chance3 = CyGame().getSorenRandNum(rmore + 1, "Random for Pinch 1 + 2 + 3")
									if ( chance3 == 0 ):
										freeprom3 = gc.getInfoTypeForString("PROMOTION_PINCH3")
										pUnit.setHasPromotion(freeprom3, true)
		##########
		# AMBUSH #
		##########
						if ( chance == 33 ):
							if ( (uct != uctNaval) ):
								freeprom1 = gc.getInfoTypeForString("PROMOTION_AMBUSH")
								pUnit.setHasPromotion(freeprom1, true)
								rmore = 5
								if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_FACTORY')) ):
									rmore = rmore - 1
								if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_MILITARY_ACADEMY')) ):
									rmore = rmore - 1
								chance2 = CyGame().getSorenRandNum(rmore, "Random for Ambush 1 + 2")
								if ( chance2 == 0 ):
									freeprom2 = gc.getInfoTypeForString("PROMOTION_AMBUSH2")
									pUnit.setHasPromotion(freeprom2, true)
									chance3 = CyGame().getSorenRandNum(rmore + 1, "Random for Ambush 1 + 2 + 3")
									if ( chance3 == 0 ):
										freeprom3 = gc.getInfoTypeForString("PROMOTION_AMBUSH3")
										pUnit.setHasPromotion(freeprom3, true)
										chance4 = CyGame().getSorenRandNum(rmore + 2, "Random for Ambush 1 + 2 + 3 + 4")
										if ( chance4 == 0 ):
											freeprom4 = gc.getInfoTypeForString("PROMOTION_AMBUSH4")
											pUnit.setHasPromotion(freeprom4, true)
		###############
		# CITY RAIDER #
		###############
						if ( chance == 34 ):
							if ( (uct != uctRecon) and (uct != uctNaval) ):
								freeprom1 = gc.getInfoTypeForString("PROMOTION_CITY_RAIDER1")
								pUnit.setHasPromotion(freeprom1, true)
								chance2 = CyGame().getSorenRandNum(10, "Random for City Raider1 + 2")
								if ( chance2 >= 8 ):
									freeprom2 = gc.getInfoTypeForString("PROMOTION_CITY_RAIDER2")
									pUnit.setHasPromotion(freeprom2, true)
									chance3 = CyGame().getSorenRandNum(10, "Random for City Raider1 + 2 + 3")
									if ( chance3 >= 8 ):
										freeprom3 = gc.getInfoTypeForString("PROMOTION_CITY_RAIDER3")
										pUnit.setHasPromotion(freeprom3, true)
										chance4 = CyGame().getSorenRandNum(10, "Random for City Raider1 + 2 + 3 + 4")
										if ( chance4 == 1 ):
											freeprom4 = gc.getInfoTypeForString("PROMOTION_CITY_RAIDER4")
											pUnit.setHasPromotion(freeprom4, true)
		##########
		# ATTACK #
		##########
						if ( chance == 35 ):
							if ( uct != uctRecon ):
								freeprom1 = gc.getInfoTypeForString("PROMOTION_ATTACK1")
								pUnit.setHasPromotion(freeprom1, true)
								chance2 = CyGame().getSorenRandNum(10, "Random for Attack1 + 2")
								if ( chance2 >= 8 ):
									freeprom2 = gc.getInfoTypeForString("PROMOTION_ATTACK2")
									pUnit.setHasPromotion(freeprom2, true)
									chance3 = CyGame().getSorenRandNum(10, "Random for Attack1 + 2 + 3")
									if ( chance3 >= 8 ):
										freeprom3 = gc.getInfoTypeForString("PROMOTION_ATTACK3")
										pUnit.setHasPromotion(freeprom3, true)
										chance4 = CyGame().getSorenRandNum(10, "Random for Attack1 + 2 + 3 + 4")
										if ( chance4 == 1 ):
											freeprom4 = gc.getInfoTypeForString("PROMOTION_ATTACK4")
											pUnit.setHasPromotion(freeprom4, true)
		##########
		# Combat #
		##########
						if ( (chance >= 36) and (chance <= 37) ):
							if pUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_COMBAT1")):
								freeprom1 = gc.getInfoTypeForString("PROMOTION_COMBAT2")
								pUnit.setHasPromotion(freeprom1, true)
								if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_BARRACKS')) ):
									chance2 = CyGame().getSorenRandNum(10, "Random for Combat2 + 3")
									if ( chance2 >= 8 ):
										freeprom2 = gc.getInfoTypeForString("PROMOTION_COMBAT3")
										pUnit.setHasPromotion(freeprom2, true)
										chance3 = CyGame().getSorenRandNum(10, "Random for Combat2 + 3 + 4")
										if ( chance3 >= 9 ):
											freeprom3 = gc.getInfoTypeForString("PROMOTION_COMBAT4")
											pUnit.setHasPromotion(freeprom3, true)
							else:
								freeprom1 = gc.getInfoTypeForString("PROMOTION_COMBAT1")
								pUnit.setHasPromotion(freeprom1, true)
								if ( pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_BARRACKS')) ):
									chance2 = CyGame().getSorenRandNum(10, "Random for Combat1 + 2")
									if ( chance2 >= 8 ):
										freeprom2 = gc.getInfoTypeForString("PROMOTION_COMBAT2")
										pUnit.setHasPromotion(freeprom2, true)
										chance3 = CyGame().getSorenRandNum(10, "Random for Combat1 + 2 + 3")
										if ( chance3 >= 9 ):
											freeprom3 = gc.getInfoTypeForString("PROMOTION_COMBAT3")
											pUnit.setHasPromotion(freeprom3, true)
		###############
		# Light/Heavy #
		###############
						if ( (chance >= 38) and (chance <= 40) ):
							if pUnit.baseMoves() > 3:
								freeprom1 = gc.getInfoTypeForString("PROMOTION_LIGHT2")
								pUnit.setHasPromotion(freeprom1, true)
							else:
								if ( pUnit.isHasPromotion(gc.getInfoTypeForString("PROMOTION_CITY_GUARD"))==false ):
									freeprom1 = gc.getInfoTypeForString("PROMOTION_LIGHT1")
									pUnit.setHasPromotion(freeprom1, true)

						if ( (chance >= 41) and (chance <= 43) ):
							if ( pUnit.baseMoves() > 1 ):
								freeprom1 = gc.getInfoTypeForString("PROMOTION_HEAVY")
								pUnit.setHasPromotion(freeprom1, true)
		#############
		# BERZERKER #
		#############
						if ( chance == 44 ):
							if ( uct != uctRecon ):
								chanceB = CyGame().getSorenRandNum(20, "Random for BERZERKER1 or 2 or 2")
								if ( chanceB <= 10 ):
									freeprom1 = gc.getInfoTypeForString("PROMOTION_BERZERKER1")
									pUnit.setHasPromotion(freeprom1, true)
									chance2 = CyGame().getSorenRandNum(20, "Random for BERZERKER1 + 3")
									if ( chance2 == 0 ):
										freeprom2 = gc.getInfoTypeForString("PROMOTION_BERZERKER3")
										pUnit.setHasPromotion(freeprom2, true)
								if ( chanceB <= 17 and chanceB >= 11 ):
									freeprom1 = gc.getInfoTypeForString("PROMOTION_BERZERKER2")
									pUnit.setHasPromotion(freeprom1, true)
								if ( chanceB <= 20 and chanceB >= 18 ):
									freeprom1 = gc.getInfoTypeForString("PROMOTION_BERZERKER3")
									pUnit.setHasPromotion(freeprom1, true)
		############
		# STALWART #
		############
						if ( chance == 45 ):
							if ( uct != uctRecon ):
								chanceB = CyGame().getSorenRandNum(20, "Random for STALWART1 or 2 or 2")
								if ( chanceB <= 10 ):
									freeprom1 = gc.getInfoTypeForString("PROMOTION_STALWART1")
									pUnit.setHasPromotion(freeprom1, true)
									chance2 = CyGame().getSorenRandNum(20, "Random for STALWART1 + 3")
									if ( chance2 == 0 ):
										freeprom2 = gc.getInfoTypeForString("PROMOTION_STALWART3")
										pUnit.setHasPromotion(freeprom2, true)
								if ( chanceB <= 17 and chanceB >= 11 ):
									freeprom1 = gc.getInfoTypeForString("PROMOTION_STALWART2")
									pUnit.setHasPromotion(freeprom1, true)
								if ( chanceB <= 20 and chanceB >= 18 ):
									freeprom1 = gc.getInfoTypeForString("PROMOTION_STALWART3")
									pUnit.setHasPromotion(freeprom1, true)
		########
		# Hero #
		########
						if ( chance == 46 ):
							promHero1 = gc.getInfoTypeForString("PROMOTION_HERO1")
							promHero2 = gc.getInfoTypeForString("PROMOTION_HERO2")
							promHero3 = gc.getInfoTypeForString("PROMOTION_HERO3")
							promHero4 = gc.getInfoTypeForString("PROMOTION_HERO4")
							promHero5 = gc.getInfoTypeForString("PROMOTION_HERO5")
							heros = 0
							
                                                        ### get all player ###
							for iiPlayer in range(gc.getMAX_PLAYERS()):
								ppPlayer = PyHelpers.PyPlayer(iiPlayer)
								if (ppPlayer.isAlive()):
                                                                        
                                                                	### get all units in the game and look for hero units ###
									unitList = ppPlayer.getUnitList()
									for iiUnit in range(len(unitList)):
										ppUnit = unitList[iiUnit]
										if ( ppUnit.isHasPromotion(promHero1)==true or ppUnit.isHasPromotion(promHero2)==true or ppUnit.isHasPromotion(promHero3)==true or ppUnit.isHasPromotion(promHero4)==true or ppUnit.isHasPromotion(promHero5)==true ):
											heros += 1
											
                                                	### only give the pUnit a hero promotion if there are less than 5 hero units in the whole game ###
							if ( heros < 5 ):
                                                                
                                                        	### you get better hero units if the pCity has a high culture lvl (higher lvl = better hero promotion) ###
								if ( pCity.getCultureLevel()==gc.getInfoTypeForString("CULTURELEVEL_LEGENDARY") ):
									freeprom1 = promHero5
									pUnit.setHasPromotion(freeprom1, true)
									chance2 = CyGame().getSorenRandNum(10, "Random for Hero1 + 5")
									if ( chance2 == 0 ):
										freeprom2 = promHero1
										pUnit.setHasPromotion(freeprom2, true)
								if ( pCity.getCultureLevel()==gc.getInfoTypeForString("CULTURELEVEL_INFLUENTIAL") ):
									freeprom1 = promHero5
									pUnit.setHasPromotion(freeprom1, true)
								if ( pCity.getCultureLevel()==gc.getInfoTypeForString("CULTURELEVEL_REFINED") ):
									freeprom1 = promHero4
									pUnit.setHasPromotion(freeprom1, true)
								if ( pCity.getCultureLevel()==gc.getInfoTypeForString("CULTURELEVEL_DEVELOPING") ):
									freeprom1 = promHero3
									pUnit.setHasPromotion(freeprom1, true)
								if ( pCity.getCultureLevel()==gc.getInfoTypeForString("CULTURELEVEL_FLEDGLING") ):
									freeprom1 = promHero2
									pUnit.setHasPromotion(freeprom1, true)
								if ( pCity.getCultureLevel()==gc.getInfoTypeForString("CULTURELEVEL_POOR") ):
									freeprom1 = promHero1
									pUnit.setHasPromotion(freeprom1, true)

                                                ### Ausgabe ###
						UnitName = PyHelpers.PyInfo.UnitInfo(pUnit.getUnitType()).getDescription()
						CityName = pCity.getName()
						if ( freeprom1!=0 and freeprom2==0 ):
							PromotionName1 = PyHelpers.PyInfo.PromotionInfo(freeprom1).getDescription()
							CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_CITY_GUARD_GAMETXT2",(CityName, PromotionName1, UnitName)),'',0,gc.getPromotionInfo(freeprom1).getButton(),ColorTypes(9), pCity.getX(), pCity.getY(),True,True)
							
							### message: In %s the City Guard Improvement provides a free %s Promotion to your new build %s ###
						if ( freeprom2!=0 and freeprom3==0 ):
							PromotionName1 = PyHelpers.PyInfo.PromotionInfo(freeprom1).getDescription()
							PromotionName2 = PyHelpers.PyInfo.PromotionInfo(freeprom2).getDescription()
							CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_CITY_GUARD_GAMETXT3",(CityName, PromotionName1, PromotionName2, UnitName)),'',0,gc.getPromotionInfo(freeprom1).getButton(),ColorTypes(9), pCity.getX(), pCity.getY(),True,True)
							
							### message: In %s the City Guard Improvement provides a free %s and %s Promotion to your new build %s ###
						if ( freeprom3!=0 and freeprom4==0 ):
							PromotionName1 = PyHelpers.PyInfo.PromotionInfo(freeprom1).getDescription()
							PromotionName2 = PyHelpers.PyInfo.PromotionInfo(freeprom2).getDescription()
							PromotionName3 = PyHelpers.PyInfo.PromotionInfo(freeprom3).getDescription()
							CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_CITY_GUARD_GAMETXT4",(CityName, PromotionName1, PromotionName2, PromotionName3, UnitName)),'',0,gc.getPromotionInfo(freeprom1).getButton(),ColorTypes(9), pCity.getX(), pCity.getY(),True,True)
							
							### message: In %s the City Guard Improvement provides a free %s, %s and %s Promotion to your new build %s ###
						if ( freeprom4!=0 and freeprom5==0 ):
							PromotionName1 = PyHelpers.PyInfo.PromotionInfo(freeprom1).getDescription()
							PromotionName2 = PyHelpers.PyInfo.PromotionInfo(freeprom2).getDescription()
							PromotionName3 = PyHelpers.PyInfo.PromotionInfo(freeprom3).getDescription()
							PromotionName4 = PyHelpers.PyInfo.PromotionInfo(freeprom4).getDescription()
							CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_CITY_GUARD_GAMETXT5",(CityName, PromotionName1, PromotionName2, PromotionName3, PromotionName4, UnitName)),'',0,gc.getPromotionInfo(freeprom1).getButton(),ColorTypes(9), pCity.getX(), pCity.getY(),True,True)
							
							### message: In %s the City Guard Improvement provides a free %s, %s, %s and %s Promotion to your new build %s ###
						if ( freeprom5!=0 ):
							PromotionName1 = PyHelpers.PyInfo.PromotionInfo(freeprom1).getDescription()
							PromotionName2 = PyHelpers.PyInfo.PromotionInfo(freeprom2).getDescription()
							PromotionName3 = PyHelpers.PyInfo.PromotionInfo(freeprom3).getDescription()
							PromotionName4 = PyHelpers.PyInfo.PromotionInfo(freeprom4).getDescription()
							PromotionName5 = PyHelpers.PyInfo.PromotionInfo(freeprom5).getDescription()
							CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_CITY_GUARD_GAMETXT6",(CityName, PromotionName1, PromotionName2, PromotionName3, PromotionName4, PromotionName5, UnitName)),'',0,gc.getPromotionInfo(freeprom1).getButton(),ColorTypes(9), pCity.getX(), pCity.getY(),True,True)
							
							### message: In %s the City Guard Improvement provides a free %s, %s, %s, %s and %s Promotion to your new build %s ###

###############################################################################################################################################
###############################################################################################################################################

        #####################################################################################################################
                #######################################
                ### Golden Age / City Guard gimmick ###
                #######################################
	#####################################################################################################################
	def goldenAgeCityGuardGimmick(self, argsList):
		'Unit Completed'

		pCity = argsList[0]
		pUnit = argsList[1]
		pPlayer = gc.getPlayer(pUnit.plot().getOwner())
		b_sw = gc.getInfoTypeForString('BUILDING_STADTWACHE')

                ### filter ###
		if ( ( (pPlayer.isGoldenAge()==true) or (pCity.hasBuilding(b_sw)) )):
			pUnitCT = pUnit.getUnitClassType()
			
                        ### filter settler ( no sense for different settlers e.g. african instead of arabian, ... ###
			if ( pUnitCT != gc.getInfoTypeForString("UNITCLASS_SETTLER") ):
                                
                        ### 10% chance for city guard gimmick without golden age / with golden age gimmick chance = 100% ###
				chance = CyGame().getSorenRandNum(10, "Random for Stadtwache")
				if ( (chance==0) or (pPlayer.isGoldenAge()==true) ):
                                        
                                        ### look, if there are units in the game with the same unit class type <-- same unit class type means uu units / the first one in the unit xml file have to be the standard unit!!! ###
					lgleicheUCU = []
					gleicheUC = 0
					for iUnitC in range(gc.getNumUnitInfos()):
						cpUnit = gc.getUnitInfo(iUnitC)
						if ( (cpUnit.getUnitClassType() == pUnitCT) ):
							lgleicheUCU.append(iUnitC)
							gleicheUC += 1
							
                                	### are there uu's for the pUnit available? ###
					if ( gleicheUC >= 2 ):
                                                
                                        	### e.g. 3 units with the same class means 1 standard and 2 uu ###
						no_standard_unit = 1
						
                                        	### in sevomod there are a few identical units (warrior/scout/worker) with different skins (native, african, ...), that means we have more standard units if we build this unit class ###
						if ( (pUnitCT==gc.getInfoTypeForString("UNITCLASS_WARRIOR")) or (pUnitCT==gc.getInfoTypeForString("UNITCLASS_SCOUT")) ):
                                                        
							### STANDARD & AFRICAN & NATIVE & FAREAST & ARABIAN ###
							no_standard_unit = 5
						elif ( pUnitCT==gc.getInfoTypeForString("UNITCLASS_WORKER") ):
                                                        
							### STANDARD & AFRICAN ###
							no_standard_unit = 2
						iX = pUnit.plot().getX()
						iY = pUnit.plot().getY()
						
                                        	### select one of the available uu's for the pUnit ###
						### "gleicheUC - 1" damit "lgleicheUCU[0]" (<-- Standard Unit) nicht generiert wird. Ausgleich: "[iRand + 1]" ###
						iRand = CyGame().getSorenRandNum( gleicheUC - no_standard_unit, "Random which new UU")
						pnewUU = lgleicheUCU[iRand + no_standard_unit]
						
                                        	### create new uu (and convert) instead of the standard pUnit ###
						pNewUnit = pPlayer.initUnit( pnewUU, iX, iY, UnitAITypes.NO_UNITAI )
						pNewUnit.convert(pUnit)

                                        	### ausgabe ###
						PyInfo = PyHelpers.PyInfo
						cppUnit = PyInfo.UnitInfo(pUnit.getUnitType())
						cppNewUnit = PyInfo.UnitInfo(pNewUnit.getUnitType())
						if (pUnit.getUnitType() != pNewUnit.getUnitType() ):
							if (pPlayer.isGoldenAge()==true):
								CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_GOLDEN_AGE_GAMETXT1",(pCity.getName(), cppNewUnit.getDescription() , cppUnit.getDescription())),'',0,'art/Interface/Buttons/actions/goldenage.dds',ColorTypes(11), iX, iY,True,True)
								
								### message: In %s the Golden Age provides a %s instead of a %s ###
							if (pPlayer.isGoldenAge()==false):
								CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_GOLDEN_AGE_GAMETXT2",(pCity.getName(), cppNewUnit.getDescription() , cppUnit.getDescription())),'',0,'art/Interface/Buttons/buildings/Stadtwache.dds',ColorTypes(44), iX, iY,True,True)
								
								### message: In %s the City Guard Improvement provides a %s instead of a %s ###

###############################################################################################################################################
###############################################################################################################################################

        #####################################################################################################################
                #########################################################################
                ### 40% chance for Paladin / Landsknecht with Castle City Improvement ###
                #########################################################################
	#####################################################################################################################
	def cityCastleImprovementFreePaladin(self, argsList):
		'Unit Completed'

		pCity = argsList[0]
		pUnit = argsList[1]
		pPlayer = gc.getPlayer(pUnit.plot().getOwner())


                ### filter ###
		if ( pUnit.getUnitType() == gc.getInfoTypeForString("UNIT_KNIGHT") or pUnit.getUnitType() == gc.getInfoTypeForString("UNIT_MACEMAN") ):
			if ( pCity.hasBuilding(gc.getInfoTypeForString("BUILDING_CASTLE")) ):
                                
                        	### 40% chance for improved units ###
				chance = CyGame().getSorenRandNum(10, "Random for Advanced Unit")
				if ( chance >= 6 ):
					pNewUnit = 0
					iX = pUnit.plot().getX()
					iY = pUnit.plot().getY()
					if ( pUnit.getUnitType() == gc.getInfoTypeForString("UNIT_KNIGHT") ):
						NewUnit = gc.getInfoTypeForString("UNIT_PALADIN")
						pNewUnit = pPlayer.initUnit( NewUnit, iX, iY, UnitAITypes.NO_UNITAI )
						pNewUnit.convert(pUnit)
					elif ( pUnit.getUnitType() == gc.getInfoTypeForString("UNIT_MACEMAN") ):
						NewUnit = gc.getInfoTypeForString("UNIT_LANDSKNECHT")
						pNewUnit = pPlayer.initUnit( NewUnit, iX, iY, UnitAITypes.NO_UNITAI )
						pNewUnit.convert(pUnit)
						
                                	### ausgabe ###
					if ( pNewUnit != 0 ):
						PyInfo = PyHelpers.PyInfo
						cppUnit = PyInfo.UnitInfo(pUnit.getUnitType())
						cppNewUnit = PyInfo.UnitInfo(pNewUnit.getUnitType())
						CyInterface().addMessage(pPlayer.getID(),false,15,CyTranslator().getText("TXT_KEY_CASTLE_GAMETXT1",(pCity.getName(), cppNewUnit.getDescription() , cppUnit.getDescription())),'',0,gc.getUnitInfo(NewUnit).getButton(),ColorTypes(11), iX, iY,True,True)
						### message: In %s you build a %s instead of a %s! ###
